diff --git a/src/msw/glcanvas.cpp b/src/msw/glcanvas.cpp index 5863b71270..edc53bc677 100644 --- a/src/msw/glcanvas.cpp +++ b/src/msw/glcanvas.cpp @@ -552,6 +552,7 @@ wxIMPLEMENT_CLASS(wxGLContext, wxObject); wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other, const wxGLContextAttrs *ctxAttrs) + : m_glContext(NULL) { const int* contextAttribs = NULL; bool needsARB = false; @@ -614,7 +615,10 @@ wxGLContext::wxGLContext(wxGLCanvas *win, wxGLContext::~wxGLContext() { // note that it's ok to delete the context even if it's the current one - wglDeleteContext(m_glContext); + if ( m_glContext ) + { + wglDeleteContext(m_glContext); + } } bool wxGLContext::SetCurrent(const wxGLCanvas& win) const diff --git a/src/osx/glcanvas_osx.cpp b/src/osx/glcanvas_osx.cpp index a91f748533..32630e4c80 100644 --- a/src/osx/glcanvas_osx.cpp +++ b/src/osx/glcanvas_osx.cpp @@ -359,6 +359,7 @@ wxGLAttributes& wxGLAttributes::Defaults() wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other, const wxGLContextAttrs *ctxAttrs) + : m_glContext(NULL) { const int* contextAttribs = NULL; int ctxSize = 0; diff --git a/src/unix/glx11.cpp b/src/unix/glx11.cpp index 52f756e259..65346010c4 100644 --- a/src/unix/glx11.cpp +++ b/src/unix/glx11.cpp @@ -454,6 +454,7 @@ wxIMPLEMENT_CLASS(wxGLContext, wxObject); wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other, const wxGLContextAttrs *ctxAttrs) + : m_glContext(NULL) { const int* contextAttribs = NULL; Bool x11Direct = True;