Fix drag and drop regression
Fix regression introduced by e4becdc3d3
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>
bb10
parent
5bb2e84a76
commit
3c21c4581d
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ public:
|
|||
|
||||
static QPixmap defaultPixmap();
|
||||
|
||||
virtual bool ownsDragObject() const;
|
||||
|
||||
private:
|
||||
QPlatformDragPrivate *d_ptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue