From c0847e91444e701ac176e088a81a01f61f885835 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 30 Jun 2014 11:14:52 +0200 Subject: [PATCH] Avoid crashing race condition. Change-Id: I940bcbc509a689804a02f71af45f5efc19bccf9f Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 9a7b7f09eb0..d04e76b503d 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -54,6 +54,7 @@ #include "qwaylandwindowmanagerintegration_p.h" #include +#include #include #include @@ -245,9 +246,14 @@ void QWaylandWindow::setVisible(bool visible) // QWaylandShmBackingStore::beginPaint(). } else { QWindowSystemInterface::handleExposeEvent(window(), QRegion()); + // when flushing the event queue, it could contain a close event, in which + // case 'this' will be deleted. When that happens, we must abort right away. + QPointer deleteGuard(this); QWindowSystemInterface::flushWindowSystemEvents(); - attach(static_cast(0), 0, 0); - commit(); + if (!deleteGuard.isNull()) { + attach(static_cast(0), 0, 0); + commit(); + } } }