summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2023-06-05 15:57:49 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-06-06 08:43:09 +0000
commit6de5032580372da8f100db7b895a5c78fe37c118 (patch)
tree6d72f6d519e69160e3d9138eb42d3f84cc936531
parenta784604de8039650db20810fd9ebcc66e866cfcb (diff)
client: Guard against client destruction in gestures
Client code can delete a window at any point. Any gesture events, including a "begin" event can be already in flight before the compositor is aware of the window destruction. It's up to the client code to handle either the focus not being initially found or the QPointer resetting and no-op. Task-number: QTBUG-113145 Change-Id: Ie2c01799bd38c6f295159876a1bcd018abe60188 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> (cherry picked from commit 5587deee20f5c12f7a9ae242758b108c1a85d7dd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/client/qwaylandpointergestures.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/client/qwaylandpointergestures.cpp b/src/client/qwaylandpointergestures.cpp
index df43c31e9..1cdd97edd 100644
--- a/src/client/qwaylandpointergestures.cpp
+++ b/src/client/qwaylandpointergestures.cpp
@@ -41,8 +41,11 @@ void QWaylandPointerGestureSwipe::zwp_pointer_gesture_swipe_v1_begin(uint32_t se
uint32_t fingers)
{
#ifndef QT_NO_GESTURES
- mParent->mSerial = serial;
mFocus = QWaylandWindow::fromWlSurface(surface);
+ if (!mFocus) {
+ return;
+ }
+ mParent->mSerial = serial;
mFingers = fingers;
const auto* pointer = mParent->pointer();
@@ -62,6 +65,9 @@ void QWaylandPointerGestureSwipe::zwp_pointer_gesture_swipe_v1_update(uint32_t t
wl_fixed_t dx, wl_fixed_t dy)
{
#ifndef QT_NO_GESTURES
+ if (!mFocus) {
+ return;
+ }
const auto* pointer = mParent->pointer();
const QPointF delta = QPointF(wl_fixed_to_double(dx), wl_fixed_to_double(dy));
@@ -79,6 +85,9 @@ void QWaylandPointerGestureSwipe::zwp_pointer_gesture_swipe_v1_end(uint32_t seri
int32_t cancelled)
{
#ifndef QT_NO_GESTURES
+ if (!mFocus) {
+ return;
+ }
mParent->mSerial = serial;
const auto* pointer = mParent->pointer();
@@ -113,11 +122,13 @@ void QWaylandPointerGesturePinch::zwp_pointer_gesture_pinch_v1_begin(uint32_t se
uint32_t fingers)
{
#ifndef QT_NO_GESTURES
- mParent->mSerial = serial;
mFocus = QWaylandWindow::fromWlSurface(surface);
+ if (!mFocus) {
+ return;
+ }
+ mParent->mSerial = serial;
mFingers = fingers;
mLastScale = 1;
-
const auto* pointer = mParent->pointer();
qCDebug(lcQpaWaylandInput) << "zwp_pointer_gesture_pinch_v1_begin @ "
@@ -137,6 +148,9 @@ void QWaylandPointerGesturePinch::zwp_pointer_gesture_pinch_v1_update(uint32_t t
wl_fixed_t rotation)
{
#ifndef QT_NO_GESTURES
+ if (!mFocus) {
+ return;
+ }
const auto* pointer = mParent->pointer();
const qreal rscale = wl_fixed_to_double(scale);
@@ -161,6 +175,9 @@ void QWaylandPointerGesturePinch::zwp_pointer_gesture_pinch_v1_end(uint32_t seri
int32_t cancelled)
{
#ifndef QT_NO_GESTURES
+ if (!mFocus) {
+ return;
+ }
mParent->mSerial = serial;
const auto* pointer = mParent->pointer();