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>
bb10
Tor Arne Vestbø 2017-04-03 16:04:05 +02:00
parent 0d12ebd7e7
commit de4aeade5e
2 changed files with 9 additions and 0 deletions

View File

@ -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
*/

View File

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