From 8fdd11465cd17006a108a6f04b2fb1bf8fc5de2f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 7 Mar 2014 10:49:33 +0100 Subject: [PATCH] Destroy backingstore before window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The window is created before the backingstore, so the destruction should happen in the reverse order. Also, the backingstore is created based on a pointer to a QWindow, so the dependency is from backingstore to window. Thirdly, this fixes a crash when using QQuickWidget/QOpenGLWidget. Task-number: QTBUG-37045 Change-Id: I6e782c553fddfeef877be30ca2610aff75a425a0 Reviewed-by: Laszlo Agocs Reviewed-by: Jørgen Lind --- src/widgets/kernel/qwidget_qpa.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 174b7eb5d5..5885673591 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -939,6 +939,12 @@ void QWidgetPrivate::createTLSysExtra() void QWidgetPrivate::deleteTLSysExtra() { if (extra && extra->topextra) { + //the qplatformbackingstore may hold a reference to the window, so the backingstore + //needs to be deleted first + extra->topextra->backingStoreTracker.destroy(); + delete extra->topextra->backingStore; + extra->topextra->backingStore = 0; + //the toplevel might have a context with a "qglcontext associated with it. We need to //delete the qglcontext before we delete the qplatformopenglcontext. //One unfortunate thing about this is that we potentially create a glContext just to @@ -950,10 +956,6 @@ void QWidgetPrivate::deleteTLSysExtra() delete extra->topextra->window; extra->topextra->window = 0; - extra->topextra->backingStoreTracker.destroy(); - delete extra->topextra->backingStore; - extra->topextra->backingStore = 0; - #ifndef QT_NO_OPENGL delete extra->topextra->shareContext; extra->topextra->shareContext = 0;