From edd555425a08f9e074f0a4d9333862636ccaae8d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 23 Feb 2015 21:15:08 +0100 Subject: [PATCH] QtOpenGL: avoid crashing if creating a QGLContext sharing with the global QOpenGLContext If one asks for the global OpenGL context via the right attribute, and then creates a QGLContext sharing with that context, Qt will create anoter, dummy QGLContext owned by the global context. At application shutdown, and specifically after ~QObject of QGuiApplication has run, the QObjectPrivate dpointer gets destroyed. That destroys the owning global QOpenGLContext, and therefore that dummy QGLContext as well. However, QGLContext dtor triggers a code path that accesses qApp as if it were still alive. That's not the case any more -- it has already been destroyed. So, introduce a check and avoid dereferencing NULL. Task-number: QTBUG-44621 Change-Id: Ic160ac99e9269db999e76229b1c7f8c53bd2be61 Reviewed-by: Laszlo Agocs --- src/opengl/qgl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 35f08e0092..0bd48b6c17 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -163,7 +163,7 @@ Q_GLOBAL_STATIC(QGLSignalProxy, theSignalProxy) QGLSignalProxy *QGLSignalProxy::instance() { QGLSignalProxy *proxy = theSignalProxy(); - if (proxy && proxy->thread() != qApp->thread()) { + if (proxy && qApp && proxy->thread() != qApp->thread()) { if (proxy->thread() == QThread::currentThread()) proxy->moveToThread(qApp->thread()); }