aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickwindow.cpp
diff options
context:
space:
mode:
authorDamien Caliste <dcaliste@free.fr>2019-02-01 14:35:21 +0100
committerDamien Caliste <dcaliste@free.fr>2019-03-13 07:50:30 +0000
commitca66d4fc23706a0f4ecfc4031f37cdd19facd836 (patch)
tree1692471602bbe3e0e4195e9e5b0370c84ed12373 /src/quick/items/qquickwindow.cpp
parent587d789fa5929f462b5744ba33a25db6c77b36fc (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). Task-number: QTBUG-73929 Change-Id: Ia48366b3f6638d5d714ceb17a2f8c7848eb20465 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r--src/quick/items/qquickwindow.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 485c0dfea7..2305a22cf7 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1641,6 +1641,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)