From daff5656e2ffbec65db73cad3c0f997e6a1e7667 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 11 Mar 2014 12:23:29 +0100 Subject: 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 --- src/widgets/kernel/qwidget_qpa.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/widgets/kernel/qwidget_qpa.cpp') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 3f0b0936c3..88a08060c1 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -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. -- cgit v1.2.3