diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-09-02 10:45:20 +0200 |
---|---|---|
committer | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-09-02 11:35:12 +0200 |
commit | f3668f88ccad6341280fbe2ca493562f80e76955 (patch) | |
tree | abfdb27cea92dd675732c61ed94fe7b8e2425a9e /src/client/qwaylandinputdevice.cpp | |
parent | aa54ad2d6e8fa5d0357bcadaf9b5a679c358728f (diff) | |
download | qtwayland-f3668f88ccad6341280fbe2ca493562f80e76955.tar.gz |
Client: Fix crash on wl_pointer.up after destroying a window
When wl_pointer version 5 was implemented, we added a raw QWaylandWindow
pointer in QWaylandPointerEvent. This is a problem, because the events
are stored, and the window may be deleted in the meantime.
This manifested itself as flakiness in tst_xdgshell::popup() which is
now fixed.
Fixes: QTBUG-77976
Change-Id: If34eee0286d5a63734535d67503378516d5768c3
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client/qwaylandinputdevice.cpp')
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 8aa0239d..f2dee75e 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -1045,8 +1045,15 @@ void QWaylandInputDevice::Pointer::flushScrollEvent() void QWaylandInputDevice::Pointer::flushFrameEvent() { - if (mFrameData.event) { - mFrameData.event->surface->handleMouse(mParent, *mFrameData.event); + if (auto *event = mFrameData.event) { + if (auto window = event->surface) { + window->handleMouse(mParent, *event); + } else if (mFrameData.event->type == QWaylandPointerEvent::Type::Release) { + // If the window has been destroyed, we still need to report an up event, but it can't + // be handled by the destroyed window (obviously), so send the event here instead. + QWindowSystemInterface::handleMouseEvent(nullptr, event->timestamp, event->local, + event->global, event->buttons, event->modifiers); + } delete mFrameData.event; mFrameData.event = nullptr; } |