[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - 4 commits - vcl/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Dec 3 23:31:48 PST 2014


 vcl/source/opengl/OpenGLContext.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit d32a03020d88410b17189d4cc84d44c749a88161
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 4 08:18:46 2014 +0100

    prevent crash when creating the platform context failed
    
    It is not a double delete. It happens when creating the platform context
    fails and therefore is not added to the list.
    
    Change-Id: I2771da48a5d791bbf500b56d8734dd53b32f3fb7

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 108e78a..1ff93cf 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -97,9 +97,9 @@ OpenGLContext::~OpenGLContext()
 #if defined( WNT )
     if (m_aGLWin.hRC)
     {
-        std::vector<HGLRC>::const_iterator itr = std::remove(vShareList.begin(), vShareList.end(), m_aGLWin.hRC);
-        assert(itr != vShareList.end());
-        vShareList.erase(itr);
+        std::vector<HGLRC>::iterator itr = std::remove(vShareList.begin(), vShareList.end(), m_aGLWin.hRC);
+        if (itr != vShareList.end())
+            vShareList.erase(itr);
 
         wglMakeCurrent( m_aGLWin.hDC, 0 );
         wglDeleteContext( m_aGLWin.hRC );
@@ -112,7 +112,9 @@ OpenGLContext::~OpenGLContext()
 #elif defined( UNX )
     if(m_aGLWin.ctx)
     {
-        vShareList.erase(std::remove( vShareList.begin(), vShareList.end(), m_aGLWin.ctx ));
+        std::vector<GLXContext>::iterator itr = std::remove( vShareList.begin(), vShareList.end(), m_aGLWin.ctx );
+        if (itr != vShareList.end())
+            vShareList.erase(itr);
 
         glXMakeCurrent(m_aGLWin.dpy, None, NULL);
         if( glGetError() != GL_NO_ERROR )
commit a09b0093ef7ab323b2f0ee06547ae4a258e7cd68
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 4 08:08:50 2014 +0100

    more asserts to detect double deletes
    
    Change-Id: I54284d34db2446f28ba778ce26ebedb584bf2780

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 3a7a1fb..108e78a 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -129,11 +129,13 @@ OpenGLContext::~OpenGLContext()
 
 void OpenGLContext::AddRef()
 {
+    assert(mnRefCount > 0);
     mnRefCount++;
 }
 
 void OpenGLContext::DeRef()
 {
+    assert(mnRefCount > 0);
     if( --mnRefCount == 0 )
         delete this;
 }
commit 85c8428797cfb047fea790e48e5a3260fcb83cc5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 4 08:05:33 2014 +0100

    add assert to detect double delete
    
    Change-Id: I13427cb698d29adb1d19b135ada91bcdfc8b8c92

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index b0bc91d..3a7a1fb 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -97,7 +97,9 @@ OpenGLContext::~OpenGLContext()
 #if defined( WNT )
     if (m_aGLWin.hRC)
     {
-        vShareList.erase(std::remove(vShareList.begin(), vShareList.end(), m_aGLWin.hRC));
+        std::vector<HGLRC>::const_iterator itr = std::remove(vShareList.begin(), vShareList.end(), m_aGLWin.hRC);
+        assert(itr != vShareList.end());
+        vShareList.erase(itr);
 
         wglMakeCurrent( m_aGLWin.hDC, 0 );
         wglDeleteContext( m_aGLWin.hRC );
commit 8e70b5bb89255e9ad5bb1f098d931c629b3343c2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 4 07:19:09 2014 +0100

    add more debugging output
    
    Change-Id: I91be83485dcd829800ca9611ab54b19d8eae19af

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 30a23b5..b0bc91d 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -65,6 +65,7 @@ OpenGLContext::OpenGLContext():
     mpPrevContext(NULL),
     mpNextContext(NULL)
 {
+    SAL_INFO("vcl.opengl", "new context: " << this);
 #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
     mbPixmap = false;
 #endif
@@ -82,6 +83,7 @@ OpenGLContext::OpenGLContext():
 
 OpenGLContext::~OpenGLContext()
 {
+    SAL_INFO("vcl.opengl", "delete context: " << this);
     ImplSVData* pSVData = ImplGetSVData();
     if( mpPrevContext )
         mpPrevContext->mpNextContext = mpNextContext;


More information about the Libreoffice-commits mailing list