From 3c21c4581dbd957d9f660dd52d0298ecef1001cb Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 7 Jan 2015 13:51:38 +0100 Subject: Fix drag and drop regression Fix regression introduced by e4becdc3d310a0dd1a6d34d0796a52b21dedeb2d Add QPlatformDrag::ownsDragObject() function, QDragManager can use the return value of this function to decide if it should take care of deleting QDrag object or platform plugin will take care of deleting QDrag. XCB platform plugins uses async dnd data delivery mechanism. It allows user to drop something and then continue working with the assurance that the target will get the data regardless of how slow the network connections are, which means that a source window should preserve QDrag data until dnd has finished. Change-Id: I1fbad7380cddec98b756698993dd397409833150 Task-number: QTBUG-43436 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/xcb/qxcbdrag.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbdrag.h | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 7037e102e2..ec0399ed5f 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -999,6 +999,8 @@ void QXcbDrag::handleFinished(const xcb_client_message_event_t *event) if (at != -1) { Transaction t = transactions.takeAt(at); + if (t.drag) + t.drag->deleteLater(); // QDragManager *manager = QDragManager::self(); // Window target = current_target; @@ -1186,6 +1188,11 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) } } +bool QXcbDrag::ownsDragObject() const +{ + return true; +} + QXcbDropData::QXcbDropData(QXcbDrag *d) : QXcbMime(), drag(d) diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index e273492837..63a344a098 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -70,12 +70,11 @@ public: virtual QMimeData *platformDropData(); - - void startDrag(); - void cancel(); - void move(const QMouseEvent *me); - void drop(const QMouseEvent *me); - void endDrag(); + void startDrag() Q_DECL_OVERRIDE; + void cancel() Q_DECL_OVERRIDE; + void move(const QMouseEvent *me) Q_DECL_OVERRIDE; + void drop(const QMouseEvent *me) Q_DECL_OVERRIDE; + void endDrag() Q_DECL_OVERRIDE; void handleEnter(QWindow *window, const xcb_client_message_event_t *event); void handlePosition(QWindow *w, const xcb_client_message_event_t *event); @@ -87,6 +86,7 @@ public: void handleFinished(const xcb_client_message_event_t *event); bool dndEnable(QXcbWindow *win, bool on); + bool ownsDragObject() const Q_DECL_OVERRIDE; void updatePixmap(); xcb_timestamp_t targetTime() { return target_time; } -- cgit v1.2.3