summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-03 16:04:05 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-04 09:36:12 +0000
commitde4aeade5ed86b008e6d497563cfcce9583b0c59 (patch)
tree67017456385ecce11d8cdb33844942b5cca434aa /src
parent0d12ebd7e7e4de2c60faa443c9e711bba281de88 (diff)
Delete QRasterWindow backingstore while window is still alive
The platform backingstore might need access to the window that the backingstore was created for, e.g. for makingCurrent to release OpenGL resources. In that case leaving it to the QRasterWindowPrivate destructor would be too late, as the QWindow was gone. This was seen on iOS, where the backingstore inherits QRasterBackingStore, and uses composeAndFlush to composit via GL. The raster backingstore cleans up these GL resources in its destructor, so the QIOSBackingStore destructor makes sure that the GL context is current for the window, resulting in a crash since the window is long gone by then. Change-Id: I5a22597842819f0fe3b580856b9e75e4fab32ae5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qrasterwindow.cpp8
-rw-r--r--src/gui/kernel/qrasterwindow.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/gui/kernel/qrasterwindow.cpp b/src/gui/kernel/qrasterwindow.cpp
index d8d448249e..73871e0f39 100644
--- a/src/gui/kernel/qrasterwindow.cpp
+++ b/src/gui/kernel/qrasterwindow.cpp
@@ -105,6 +105,14 @@ QRasterWindow::QRasterWindow(QWindow *parent)
d_func()->backingstore.reset(new QBackingStore(this));
}
+QRasterWindow::~QRasterWindow()
+{
+ Q_D(QRasterWindow);
+ // Delete backingstore while window is still alive, as it
+ // might need to reference the window in the process
+ d->backingstore.reset(nullptr);
+}
+
/*!
\internal
*/
diff --git a/src/gui/kernel/qrasterwindow.h b/src/gui/kernel/qrasterwindow.h
index 76312bcda2..9b29183ad6 100644
--- a/src/gui/kernel/qrasterwindow.h
+++ b/src/gui/kernel/qrasterwindow.h
@@ -54,6 +54,7 @@ class Q_GUI_EXPORT QRasterWindow : public QPaintDeviceWindow
public:
explicit QRasterWindow(QWindow *parent = Q_NULLPTR);
+ ~QRasterWindow();
protected:
int metric(PaintDeviceMetric metric) const Q_DECL_OVERRIDE;