opengl: Do not crash when programGuard is a nullptr
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>
Sat, 19 Nov 2011 19:57:14 +0000 (20:57 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 1 Dec 2011 09:51:10 +0000 (10:51 +0100)
The rest of the code is checking programGuard for nullptr, do it here
as well to prevent a segmentation fault.

Change-Id: I38a03f74d493b8f731157be1739707b39904f7ba
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/gui/opengl/qopenglshaderprogram.cpp
src/opengl/qglshaderprogram.cpp

index 13f0b1d..70f9b04 100644 (file)
@@ -936,7 +936,7 @@ void QOpenGLShaderProgram::release()
 {
     Q_D(QOpenGLShaderProgram);
 #ifndef QT_NO_DEBUG
-    if (d->programGuard->group() != QOpenGLContextGroup::currentContextGroup())
+    if (d->programGuard && d->programGuard->group() != QOpenGLContextGroup::currentContextGroup())
         qWarning("QOpenGLShaderProgram::release: program is not valid in the current context.");
 #endif
     d->glfuncs->glUseProgram(0);
index 0163d60..af093bc 100644 (file)
@@ -980,7 +980,7 @@ void QGLShaderProgram::release()
 {
 #ifndef QT_NO_DEBUG
     Q_D(QGLShaderProgram);
-    if (d->programGuard->group() != QOpenGLContextGroup::currentContextGroup())
+    if (d->programGuard && d->programGuard->group() != QOpenGLContextGroup::currentContextGroup())
         qWarning("QGLShaderProgram::release: program is not valid in the current context.");
 #endif
 #if defined(QT_OPENGL_ES_2)