From d88e56f3a569245aa0642cb7468e70d2d5f6ffa0 Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Mon, 31 Aug 2026 11:32:36 +0800 Subject: [PATCH] fix: resolve QML Drag.active binding loop warnings in windowed launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the binding loop detected for property "active" in the windowed launcher. Both IconItemDelegate and FreeSortListView bound Drag.active to the very MouseArea.drag.active property that drives it while reading Drag.active back on the same item (opacity/states/delayRemove), which QML reports as a binding loop. Set Drag.active imperatively from the MouseArea's drag.onActiveChanged handler instead of a binding. 修复窗口启动器的 Drag.active 属性绑定循环告警。 IconItemDelegate 与 FreeSortListView 都将 Drag.active 绑定到驱动它自身的 MouseArea.drag.active,同时又在同一控件上反向读取 Drag.active (用于 opacity/states/delayRemove),触发 QML 绑定循环告警。 现改为在 mouseArea 的 drag.onActiveChanged 处理器中命令式赋值 Drag.active,从而消除该绑定环。 PMS: TASK-394335 --- qml/windowed/FreeSortListView.qml | 8 +++++++- qml/windowed/IconItemDelegate.qml | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/qml/windowed/FreeSortListView.qml b/qml/windowed/FreeSortListView.qml index 3bb6a2a4..78e06617 100644 --- a/qml/windowed/FreeSortListView.qml +++ b/qml/windowed/FreeSortListView.qml @@ -315,7 +315,10 @@ Item { Drag.hotSpot.x: width / 3 Drag.hotSpot.y: height / 2 Drag.dragType: Drag.Automatic - Drag.active: mouseArea.drag.active + // Binding Drag.active to mouseArea.drag.active would make Drag.active + // read back the very property it drives (opacity/delayRemove/onActiveChanged), + // causing a QML binding loop. Set it imperatively from the MouseArea instead. + Drag.active: false Drag.mimeData: Helper.generateDragMimeData(model.desktopId) Drag.onActiveChanged: function() { if (!Drag.active) { @@ -341,6 +344,9 @@ Item { acceptedButtons: Qt.LeftButton | Qt.RightButton drag.target: dndTarget + drag.onActiveChanged: function () { + itemDelegate.Drag.active = drag.active + } TapHandler { acceptedDevices: PointerDevice.TouchScreen diff --git a/qml/windowed/IconItemDelegate.qml b/qml/windowed/IconItemDelegate.qml index d5fa0ea7..9a8b403c 100644 --- a/qml/windowed/IconItemDelegate.qml +++ b/qml/windowed/IconItemDelegate.qml @@ -25,7 +25,11 @@ Control { signal menuTriggered() Drag.dragType: Drag.Automatic - Drag.active: mouseArea.drag.active + // Binding Drag.active to mouseArea.drag.active would make Drag.active read + // back the very property it drives (used in opacity/states below), causing a + // QML binding loop. Set it imperatively from the MouseArea's drag handler + // instead. + Drag.active: false states: State { name: "dragged"; @@ -52,6 +56,9 @@ Control { enabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton drag.target: root.dndEnabled ? root : null + drag.onActiveChanged: function () { + root.Drag.active = drag.active + } onPressed: function (mouse) { if (mouse.button === Qt.LeftButton && root.dndEnabled) { appIcon.grabToImage(function(result) {