Destroy backingstore before window

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 <laszlo.agocs@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
bb10
Paul Olav Tvete 2014-03-07 10:49:33 +01:00 committed by The Qt Project
parent be81c58845
commit 8fdd11465c
1 changed files with 6 additions and 4 deletions

View File

@ -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;