aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/CMakeLists.txt
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2026-08-12 17:44:25 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2026-09-29 20:27:10 +0000
commit14872f4a7b60aff711b64da2ae672ef28750b514 (patch)
tree01d3c16ca3b9bb447f0d549b0d3799ba5562c45e /tests/auto/quick/CMakeLists.txt
parentaa5b68e09ea9032f17c9fb02f6716c78525b80ca (diff)
Handle the dragged item being destroyed during a native drag
Drag.dragType: Drag.Automatic goes through QDrag::exec(), which blocks in a nested event loop. Anything happening inside that loop can destroy the item the Drag attached object belongs to -- a ListView recycling the delegate that is being dragged is enough, which is what auto-scrolling during a drag does. Both the QQuickDragAttached and the QDrag are QObject children of that item, so they are deleted with it, and every line after exec() in startDrag() then runs on freed memory: the reported crash is in the dragFinished() emission. ~QQuickItem notifies its change listeners before ~QObject deletes its children, so that is the last point at which the drag can still be wound down by an object that is still alive. Listen for Destroyed for the duration of a native drag and do it from there: cancel the platform drag, which unwinds the nested loop and delivers the drag leave that the drop target is waiting for, then report the drag as finished and inactive. Guard the QDrag and the attached object itself across exec() for whatever gets there first. Nothing here knows about item views, so it covers TableView, PathView, Repeater and plain delegate models as well, and any route to the item's destruction rather than only recycling. It does not try to keep the item alive; an application that wants the drag to survive can still use ListView.delayRemove: Drag.active. The new test drives the nested event loop, which needs a QPlatformDrag that runs in-process. It therefore runs on the offscreen platform, and skips if that platform's drag implementation is a stub. Fixes: QTBUG-124663 Pick-to: 6.12 Change-Id: I51c6719bcc9ea0e381a314f68f2f335caa96e616 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'tests/auto/quick/CMakeLists.txt')
-rw-r--r--tests/auto/quick/CMakeLists.txt1
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/auto/quick/CMakeLists.txt b/tests/auto/quick/CMakeLists.txt
index 035f960010..18ef46d300 100644
--- a/tests/auto/quick/CMakeLists.txt
+++ b/tests/auto/quick/CMakeLists.txt
@@ -43,6 +43,7 @@ if(QT_FEATURE_private_tests)
endif()
add_subdirectory(qquickdrag)
add_subdirectory(qquickdragattached)
+ add_subdirectory(qquicknativedrag)
add_subdirectory(qquickdroparea)
add_subdirectory(qquickdynamicpropertyanimation)
add_subdirectory(qquickflickable)