Details
-
Bug
-
Resolution: Duplicate
-
P3: Somewhat important
-
5.6
-
None
-
Fedora 23, Qt5.6, gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
-
28dffdecdad4f3458b9aacec1a04803c7b5483a1
Description
When trying to track the lifetime of a drag&drop operation I noticed that the QDrag destructor will only be called if the drop is accepted by the target. If not the QDrag object stays in memory until the Qt application terminates.
A more complete elaboration can be found here: http://stackoverflow.com/questions/37846843
This is the code I can reproduce the behavior with:
#include <QtWidgets> #include <iostream> struct TrackedMimeData : public QMimeData { TrackedMimeData(const QString & text) { std::cout << this << std::endl; setText(text); } ~TrackedMimeData() { std::cout << "~" << this << std::endl; } }; struct MyListWidget : QListWidget { MyListWidget() { setDragEnabled(true); addItem("item1"); addItem("item2"); } QMimeData * mimeData(const QList<QListWidgetItem *>) const override { return new TrackedMimeData("hello"); } }; int main(int argsc, char *argsv[]) { QApplication application(argsc, argsv); MyListWidget gui; gui.show(); return application.exec(); }
Output:
0xa58750 0xa4e0f0 ~0xa4e0f0 0xa3c6c0 ~0xa3c6c0 0xa51880 0xa5ecd0 0xa31f50 0xa57db0 0xa5afc0 ~0xa5afc0 0xa5aa70 ~0xa5aa70 ------ CLOSE WINDOW ~0xa58750 ~0xa51880 ~0xa5ecd0 ~0xa31f50 ~0xa57db0
Expected output:
0xa58750 ~0xa58750 0xa4e0f0 ~0xa4e0f0 0xa3c6c0 ~0xa3c6c0 0xa51880 ~0xa51880 0xa5ecd0 ~0xa5ecd0 0xa31f50 ~0xa31f50 0xa57db0 ~0xa57db0 0xa5afc0 ~0xa5afc0 0xa5aa70 ~0xa5aa70
Attachments
Issue Links
- duplicates
-
QTBUG-53990 [Linux] QDrag is never release if aborted
- Closed