summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@theqtcompany.com>2015-01-07 13:51:38 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2015-01-19 08:15:54 +0100
commit3c21c4581dbd957d9f660dd52d0298ecef1001cb (patch)
tree5d510bc151f053e63acd572d5e9e626c772b128d /src
parent5bb2e84a764f611cf4470f2ddc0bb427c4d110cc (diff)
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 <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qdnd.cpp3
-rw-r--r--src/gui/kernel/qplatformdrag.cpp12
-rw-r--r--src/gui/kernel/qplatformdrag.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp7
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.h12
5 files changed, 29 insertions, 7 deletions
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index f515fe18df..2a6cc4fc99 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -134,7 +134,8 @@ Qt::DropAction QDragManager::drag(QDrag *o)
QGuiApplicationPrivate::instance()->notifyDragStarted(o);
const Qt::DropAction result = m_platformDrag->drag(m_object);
m_object = 0;
- o->deleteLater();
+ if (!m_platformDrag->ownsDragObject())
+ o->deleteLater();
return result;
}
diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp
index 8a5c7264d1..326f092ead 100644
--- a/src/gui/kernel/qplatformdrag.cpp
+++ b/src/gui/kernel/qplatformdrag.cpp
@@ -241,6 +241,18 @@ QPixmap QPlatformDrag::defaultPixmap()
return *qt_drag_default_pixmap();
}
+/*!
+ \since 5.4
+ \brief Returns bool indicating whether QPlatformDrag takes ownership
+ and therefore responsibility of deleting the QDrag object passed in
+ from QPlatformDrag::drag. This can be useful on platforms where QDrag
+ object has to be kept around.
+ */
+bool QPlatformDrag::ownsDragObject() const
+{
+ return false;
+}
+
#endif // QT_NO_DRAGANDDROP
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h
index 34ad11e45f..ce7a9aa1f2 100644
--- a/src/gui/kernel/qplatformdrag.h
+++ b/src/gui/kernel/qplatformdrag.h
@@ -98,6 +98,8 @@ public:
static QPixmap defaultPixmap();
+ virtual bool ownsDragObject() const;
+
private:
QPlatformDragPrivate *d_ptr;
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; }