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>
This commit is contained in:
parent
93985ff126
commit
f199375e5c
@ -1045,8 +1045,15 @@ void QWaylandInputDevice::Pointer::flushScrollEvent()
|
|||||||
|
|
||||||
void QWaylandInputDevice::Pointer::flushFrameEvent()
|
void QWaylandInputDevice::Pointer::flushFrameEvent()
|
||||||
{
|
{
|
||||||
if (mFrameData.event) {
|
if (auto *event = mFrameData.event) {
|
||||||
mFrameData.event->surface->handleMouse(mParent, *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;
|
delete mFrameData.event;
|
||||||
mFrameData.event = nullptr;
|
mFrameData.event = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ public:
|
|||||||
QPoint pixelDelta;
|
QPoint pixelDelta;
|
||||||
QPoint angleDelta;
|
QPoint angleDelta;
|
||||||
Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
|
Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
|
||||||
QWaylandWindow *surface = nullptr;
|
QPointer<QWaylandWindow> surface;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user