diff options
author | Damien Caliste <dcaliste@free.fr> | 2019-02-01 14:35:21 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-04-30 11:48:40 +0200 |
commit | 2bd0d02016913aa95d0b099d77e7ad4aa32f16ee (patch) | |
tree | 04e54968946321528834fe8bc003d2408c574ae8 /src | |
parent | e18b943645d53bb7b7b7e7485b10d1ac4854c663 (diff) |
Ask rendering thread to release resources when window is closed
If the close event is accepted, the close handler in QWindow will
destroy the underlying platform window without notifying the
QSGRenderer attribute windowManager. This may cause a race
condition if the renderer is a QSGThreadedRenderLoop because
the platform window may be deleted while the thread is using it.
Correct this issue by notifying the QSGRenderer on a close event
using the hide() method (which is supposed to release the
resources according to documentation).
Fixes: QTBUG-82474
Task-number: QTBUG-73929
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit ca66d4fc23706a0f4ecfc4031f37cdd19facd836)
Change-Id: Ia8d76a4471270ca90af7c201e7ad4477609b9c36
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index c55db04566..2c89ebd380 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1655,6 +1655,14 @@ bool QQuickWindow::event(QEvent *e) emit closing(&qev); e->setAccepted(qev.isAccepted()); } break; + case QEvent::PlatformSurface: + if ((static_cast<QPlatformSurfaceEvent *>(e))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) { + // Ensure that the rendering thread is notified before + // the QPlatformWindow is destroyed. + if (d->windowManager) + d->windowManager->hide(this); + } + break; case QEvent::FocusAboutToChange: #if QT_CONFIG(im) if (d->activeFocusItem) |