Null out QOpenGLContext::screen upon screen disconnect
Returning a dangling pointer is no good. Do what QOffscreenSurface does: just null it out. Task-number: QTBUG-42803 Change-Id: I01a6db9ae8974a1c78157ebc67097c8dac3a6b6e Reviewed-by: Gunnar Sletta <gunnar@sletta.org>bb10
parent
9e81fb4df6
commit
eecc351c5d
|
|
@ -462,8 +462,7 @@ QPlatformOpenGLContext *QOpenGLContext::shareHandle() const
|
|||
QOpenGLContext::QOpenGLContext(QObject *parent)
|
||||
: QObject(*new QOpenGLContextPrivate(), parent)
|
||||
{
|
||||
Q_D(QOpenGLContext);
|
||||
d->screen = QGuiApplication::primaryScreen();
|
||||
setScreen(QGuiApplication::primaryScreen());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -499,9 +498,20 @@ void QOpenGLContext::setShareContext(QOpenGLContext *shareContext)
|
|||
void QOpenGLContext::setScreen(QScreen *screen)
|
||||
{
|
||||
Q_D(QOpenGLContext);
|
||||
if (d->screen)
|
||||
disconnect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
|
||||
d->screen = screen;
|
||||
if (!d->screen)
|
||||
d->screen = QGuiApplication::primaryScreen();
|
||||
if (d->screen)
|
||||
connect(d->screen, SIGNAL(destroyed(QObject*)), this, SLOT(_q_screenDestroyed(QObject*)));
|
||||
}
|
||||
|
||||
void QOpenGLContextPrivate::_q_screenDestroyed(QObject *object)
|
||||
{
|
||||
Q_Q(QOpenGLContext);
|
||||
if (object == static_cast<QObject *>(screen))
|
||||
q->setScreen(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -1626,4 +1636,6 @@ void QOpenGLMultiGroupSharedResource::cleanup(QOpenGLContextGroup *group, QOpenG
|
|||
m_groups.removeOne(group);
|
||||
}
|
||||
|
||||
#include "moc_qopenglcontext.cpp"
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ private:
|
|||
void setTextureFunctions(QOpenGLTextureHelper* textureFuncs);
|
||||
|
||||
void destroy();
|
||||
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_screenDestroyed(QObject *object))
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -270,6 +270,8 @@ public:
|
|||
static QHash<QOpenGLContext *, bool> makeCurrentTracker;
|
||||
static QMutex makeCurrentTrackerMutex;
|
||||
#endif
|
||||
|
||||
void _q_screenDestroyed(QObject *object);
|
||||
};
|
||||
|
||||
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
|
||||
|
|
|
|||
Loading…
Reference in New Issue