diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-12-04 08:18:46 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-12-04 08:30:49 +0100 |
commit | d32a03020d88410b17189d4cc84d44c749a88161 (patch) | |
tree | 8c45beb65d9e7f8885d35b9206560da4db99ce86 | |
parent | a09b0093ef7ab323b2f0ee06547ae4a258e7cd68 (diff) |
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
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 108e78a1cbe7..1ff93cfa9241 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 ) |