summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorArjen Hiemstra <ahiemstra@heimr.nl>2021-11-18 13:05:30 +0100
committerArjen Hiemstra <ahiemstra@heimr.nl>2021-12-09 13:57:23 +0100
commit39e3290efa2dd40722fa3322284cae3b01ccedf4 (patch)
tree8a0287a2769b9b20752815cf7f662db6b9b4a466 /src/client
parentbd6dbf01f13007c20f93080d59b26d3635a81a9d (diff)
downloadqtwayland-39e3290efa2dd40722fa3322284cae3b01ccedf4.tar.gz
Client: Delay deletion of QDrag object until after we're done with it
In certain cases, most notably when performing drag and drop operations with touch, the QDrag object gets deleted before data_source_send is executed. This then tries to access a deleted data_source, crashing the client. To avoid this, we indicate we want the QDrag object to stay around and then delete it in QWaylandDrag::finishDrag, which with data_device v3 is guaranteed to be called after everyone is done with the data source. Change-Id: I6a2f5a219f58d1b721a9fec33c57d26d2c522ec9 Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src/client')
-rw-r--r--src/client/qwaylanddnd.cpp11
-rw-r--r--src/client/qwaylanddnd_p.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp
index 97ee5b2e..7c53f5fa 100644
--- a/src/client/qwaylanddnd.cpp
+++ b/src/client/qwaylanddnd.cpp
@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
QBasicDrag::cancel();
m_display->currentInputDevice()->dataDevice()->cancelDrag();
+
+ if (drag())
+ drag()->deleteLater();
}
void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
@@ -130,6 +133,14 @@ void QWaylandDrag::finishDrag()
{
QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
eventFilter(shapedPixmapWindow(), &event);
+
+ if (drag())
+ drag()->deleteLater();
+}
+
+bool QWaylandDrag::ownsDragObject() const
+{
+ return true;
}
}
diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h
index 747f0190..46f629ac 100644
--- a/src/client/qwaylanddnd_p.h
+++ b/src/client/qwaylanddnd_p.h
@@ -83,6 +83,7 @@ protected:
void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
void endDrag() override;
+ bool ownsDragObject() const override;
private:
QWaylandDisplay *m_display = nullptr;