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 <laszlo.agocs@theqtcompany.com>
This commit is contained in:
Giuseppe D'Angelo 2015-02-23 21:15:08 +01:00
parent e9d07be949
commit edd555425a

View File

@ -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());
}