QQuickWidget: fix crash on exit

Make sure that the correct context is current when freeing GL resources.
Otherwise, on shutdown, QOpenGLVertexArrayObject would try to use the
previously current context, which mmay already have been deleted.

Task-number: QTBUG-37385
Change-Id: Ib2332f54636738a1a4b1041a7dcbffd0af00261d
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
Paul Olav Tvete 2014-03-11 12:23:29 +01:00 committed by The Qt Project
parent afbad00a4d
commit daff5656e2

View File

@ -945,10 +945,21 @@ void QWidgetPrivate::deleteTLSysExtra()
{
if (extra && extra->topextra) {
//the qplatformbackingstore may hold a reference to the window, so the backingstore
//needs to be deleted first
//needs to be deleted first. If the backingstore holds GL resources, we need to
// make the context current here, since the platform bs does not have a reference
// to the widget.
#ifndef QT_NO_OPENGL
if (textureChildSeen && extra->topextra->shareContext)
extra->topextra->shareContext->makeCurrent(extra->topextra->window);
#endif
extra->topextra->backingStoreTracker.destroy();
delete extra->topextra->backingStore;
extra->topextra->backingStore = 0;
#ifndef QT_NO_OPENGL
if (textureChildSeen && extra->topextra->shareContext)
extra->topextra->shareContext->doneCurrent();
#endif
//the toplevel might have a context with a "qglcontext associated with it. We need to
//delete the qglcontext before we delete the qplatformopenglcontext.