Blame SOURCES/0040-Client-Delay-deletion-of-QDrag-object-until-after-we.patch

429548
From 0b15df7e9e26a4edfc2277eb3ec7b3d5c58a5dcd Mon Sep 17 00:00:00 2001
429548
From: Arjen Hiemstra <ahiemstra@heimr.nl>
429548
Date: Thu, 18 Nov 2021 13:05:30 +0100
429548
Subject: [PATCH 40/41] Client: Delay deletion of QDrag object until after
429548
 we're done with it
429548
429548
In certain cases, most notably when performing drag and drop operations
429548
with touch, the QDrag object gets deleted before data_source_send is
429548
executed. This then tries to access a deleted data_source, crashing the
429548
client.
429548
429548
To avoid this, we indicate we want the QDrag object to stay around and
429548
then delete it in QWaylandDrag::finishDrag, which with data_device v3 is
429548
guaranteed to be called after everyone is done with the data source.
429548
429548
Change-Id: I6a2f5a219f58d1b721a9fec33c57d26d2c522ec9
429548
Reviewed-by: David Edmundson <davidedmundson@kde.org>
429548
(cherry picked from commit 39e3290efa2dd40722fa3322284cae3b01ccedf4)
429548
---
429548
 src/client/qwaylanddnd.cpp | 11 +++++++++++
429548
 src/client/qwaylanddnd_p.h |  1 +
429548
 2 files changed, 12 insertions(+)
429548
429548
diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp
429548
index 97ee5b2e..7c53f5fa 100644
429548
--- a/src/client/qwaylanddnd.cpp
429548
+++ b/src/client/qwaylanddnd.cpp
429548
@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
429548
     QBasicDrag::cancel();
429548
 
429548
     m_display->currentInputDevice()->dataDevice()->cancelDrag();
429548
+
429548
+    if (drag())
429548
+        drag()->deleteLater();
429548
 }
429548
 
429548
 void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
429548
@@ -130,6 +133,14 @@ void QWaylandDrag::finishDrag()
429548
 {
429548
     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
429548
     eventFilter(shapedPixmapWindow(), &event);
429548
+
429548
+    if (drag())
429548
+        drag()->deleteLater();
429548
+}
429548
+
429548
+bool QWaylandDrag::ownsDragObject() const
429548
+{
429548
+    return true;
429548
 }
429548
 
429548
 }
429548
diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h
429548
index 747f0190..46f629ac 100644
429548
--- a/src/client/qwaylanddnd_p.h
429548
+++ b/src/client/qwaylanddnd_p.h
429548
@@ -83,6 +83,7 @@ protected:
429548
     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
429548
     void endDrag() override;
429548
 
429548
+    bool ownsDragObject() const override;
429548
 
429548
 private:
429548
     QWaylandDisplay *m_display = nullptr;
429548
-- 
429548
2.34.1
429548