From c2e1cecfb98e7c4c9400113e13b3101c50ebc52f Mon Sep 17 00:00:00 2001 From: wangjinrun Date: Thu, 20 Aug 2026 16:34:51 +0800 Subject: [PATCH] fix(dock): eliminate several QML runtime/compile warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. ShellSurfaceItemProxy: set Connections.ignoreUnknownSignals so the cursorShapeRequested handler no longer warns for surfaces lacking the signal. 2. TaskManager: replace the deprecated ListView.onAdd NumberAnimation object-to-signal-handler assignment with a declarative add Transition. 3. TaskManager: break the implicitWidth/implicitHeight binding loop by returning the dock size directly in the spanning layout direction. 4. AppItem/DragItem/ActionLegacyTrayPluginDelegate: pass an explicit target size to grabToImage to avoid the Ignoring sourceSize request warning. 5. OverlapNotify: guard the panelShown lookup so an undefined ListView.view no longer assigns undefined to a bool property. 6. trayitempositionmanager: register the DropIndex gadget as dropIndex lowercase so qmltyperegistrar stops warning about its value-type name. 7. trayitempositionmanager: use Qt::QueuedConnection for the dockHeightChanged -> updateVisualSize connection, breaking the synchronous C++ signal/slot cascade that causes "Binding loop detected for dockItemMaxSize". When dockSize changes (e.g. during drag), dockHeightChanged previously fired synchronously, calling updateVisualSize -> setProperty("visualSize") -> visualSizeChanged, which marked dockItemMaxSize dirty (it transitively reads visualSize via dockRawCenterSpace -> dockRightPart -> tray). Queuing the slot lets the current binding evaluation finish before visualSize updates. Log: fix multiple QML warnings reported by journalctl/qmltyperegistrar Influence: 1. Verify dock shell surface cursor shape handling still works 2. Verify task manager item add animation still plays 3. Verify dock auto-size layout is unchanged 4. Verify drag image rendering for dock and tray items 5. Verify notification overlap animation initialization 6. Verify dock icon size after dragging dock height 7. Verify no "Binding loop for dockItemMaxSize" warnings during drag fix(dock): 消除任务栏与通知中心若干 QML 运行时/注册告警 1. ShellSurfaceItemProxy:为 Connections 设置 ignoreUnknownSignals, 使 cursorShapeRequested 处理器对缺少该信号的 surface 不再告警。 2. TaskManager:将弃用的 ListView.onAdd NumberAnimation 对象赋值给 信号处理器的写法改为声明式 add Transition。 3. TaskManager:在占满布局方向直接返回 dock 尺寸,打断 implicitWidth/implicitHeight 绑定环。 4. AppItem/DragItem/ActionLegacyTrayPluginDelegate:为 grabToImage 传入 显式目标尺寸,避免 Ignoring sourceSize request 告警。 5. OverlapNotify:对 panelShown 查询加空值守卫,避免未定义的 ListView.view 将 undefined 赋给 bool 属性。 6. trayitempositionmanager:将 DropIndex gadget 注册为 dropIndex 小写,使 qmltyperegistrar 不再告警其值类型名。 7. trayitempositionmanager:将 dockHeightChanged 到 updateVisualSize 的连接改为 Qt::QueuedConnection,打断同步 C++ 信号/槽级联,解决 "Binding loop detected for dockItemMaxSize"。dockSize 变化时(如 拖拽),dockHeightChanged 此前同步触发 updateVisualSize -> setProperty("visualSize") -> visualSizeChanged,使 dockItemMaxSize (经 dockRawCenterSpace -> dockRightPart -> tray 间接读取 visualSize) 被标记为脏。改为队列连接后,当前绑定求值可先完成,visualSize 在 下一次事件循环中更新,不再触发绑定环。 Log: 修复 journalctl/qmltyperegistrar 报告的多项 QML 告警 Influence: 1. 验证任务栏 shell surface 光标形状处理仍正常 2. 验证任务管理器条目添加动画仍播放 3. 验证任务栏自适应尺寸布局不变 4. 验证任务栏与托盘条目拖拽图像渲染 5. 验证通知重叠动画初始化 6. 验证拖拽任务栏高度后图标尺寸正确 7. 验证拖拽时不再出现 "Binding loop for dockItemMaxSize" 告警 PMS: TASK-394379 --- panels/dock/ShellSurfaceItemProxy.qml | 1 + panels/dock/taskmanager/package/AppItem.qml | 2 +- .../dock/taskmanager/package/TaskManager.qml | 28 +++++++++---------- .../ActionLegacyTrayPluginDelegate.qml | 4 +-- panels/dock/tray/quickpanel/DragItem.qml | 2 +- panels/dock/tray/trayitempositionmanager.cpp | 9 +++++- panels/dock/tray/trayitempositionmanager.h | 2 +- panels/notification/center/OverlapNotify.qml | 2 +- 8 files changed, 29 insertions(+), 21 deletions(-) diff --git a/panels/dock/ShellSurfaceItemProxy.qml b/panels/dock/ShellSurfaceItemProxy.qml index e55eaea63..298f39489 100644 --- a/panels/dock/ShellSurfaceItemProxy.qml +++ b/panels/dock/ShellSurfaceItemProxy.qml @@ -114,6 +114,7 @@ Item { } Connections { + ignoreUnknownSignals: true target: shellSurface // TODO it's maybe a bug for qt, we force shellSurface's value to update function onAboutToDestroy() diff --git a/panels/dock/taskmanager/package/AppItem.qml b/panels/dock/taskmanager/package/AppItem.qml index f4233a7fb..d4dd65df3 100644 --- a/panels/dock/taskmanager/package/AppItem.qml +++ b/panels/dock/taskmanager/package/AppItem.qml @@ -518,7 +518,7 @@ Item { if (mouse.button === Qt.LeftButton) { appItem.grabToImage(function(result) { root.Drag.imageSource = result.url; - }) + }, Qt.size(appItem.width, appItem.height)) } toolTip.close() closeItemPreview() diff --git a/panels/dock/taskmanager/package/TaskManager.qml b/panels/dock/taskmanager/package/TaskManager.qml index 1177a52d9..cf7415b53 100644 --- a/panels/dock/taskmanager/package/TaskManager.qml +++ b/panels/dock/taskmanager/package/TaskManager.qml @@ -40,16 +40,16 @@ ContainmentItem { readonly property real startPadding: Math.max(0, appTitleSpacing - (Panel.rootObject.dockItemMaxSize * (multitaskViewIconRatio - iconWidthToMaxSizeRatio) / 2)) implicitWidth: { - let extra = useColumnLayout ? 0 : startPadding + if (useColumnLayout) return Panel.rootObject.dockSize + let extra = startPadding let w = appContainer.implicitWidth + extra - let maxW = Panel.itemAlignment === Dock.LeftAlignment ? Math.max(remainingSpacesForTaskManager, w) : Math.min(remainingSpacesForTaskManager, w) - return useColumnLayout ? Panel.rootObject.dockSize : maxW + return Panel.itemAlignment === Dock.LeftAlignment ? Math.max(remainingSpacesForTaskManager, w) : Math.min(remainingSpacesForTaskManager, w) } implicitHeight: { - let extra = useColumnLayout ? startPadding : 0 + if (!useColumnLayout) return Panel.rootObject.dockSize + let extra = startPadding let h = appContainer.implicitHeight + extra - let maxH = Panel.itemAlignment === Dock.LeftAlignment ? Math.max(remainingSpacesForTaskManager, h) : Math.min(remainingSpacesForTaskManager, h) - return useColumnLayout ? maxH : Panel.rootObject.dockSize + return Panel.itemAlignment === Dock.LeftAlignment ? Math.max(remainingSpacesForTaskManager, h) : Math.min(remainingSpacesForTaskManager, h) } // Helper function to find the current index of an app by its appId in the visualModel function findAppIndex(appId) { @@ -114,6 +114,14 @@ ContainmentItem { duration: 200 } } + add: Transition { + NumberAnimation { + properties: "scale,opacity" + from: 0 + to: 1 + duration: 200 + } + } model: DelegateModel { id: visualModel model: taskmanager.Applet.dataModel @@ -140,14 +148,6 @@ ContainmentItem { return windows.length > 0 && launcherDndDropArea.launcherDndWinId !== windows[0] } - ListView.onAdd: NumberAnimation { - target: delegateRoot - properties: "scale,opacity" - from: 0 - to: 1 - duration: 200 - } - states: [ State { name: "item-visible" diff --git a/panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml b/panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml index 1b0ef555a..652aa3806 100644 --- a/panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml +++ b/panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml @@ -178,7 +178,7 @@ AppletItemButton { if (Qt.platform.pluginName !== "xcb") { root.grabToImage(function(result) { root.Drag.imageSource = result.url; - }) + }, Qt.size(root.width, root.height)) } if (!Drag.active) { @@ -194,7 +194,7 @@ AppletItemButton { if (Qt.platform.pluginName !== "xcb") { root.grabToImage(function(result) { root.Drag.imageSource = result.url; - }) + }, Qt.size(root.width, root.height)) } } diff --git a/panels/dock/tray/quickpanel/DragItem.qml b/panels/dock/tray/quickpanel/DragItem.qml index 8f225df64..df6c699c9 100644 --- a/panels/dock/tray/quickpanel/DragItem.qml +++ b/panels/dock/tray/quickpanel/DragItem.qml @@ -146,7 +146,7 @@ Item { draggingImage = result.url Qt.callLater(function() { dragItem.Drag.active = true }) - }) + }, Qt.size(dragItem.width, dragItem.height)) } else { dragItem.Drag.active = false } diff --git a/panels/dock/tray/trayitempositionmanager.cpp b/panels/dock/tray/trayitempositionmanager.cpp index 346f8b1ad..c68cb5d34 100644 --- a/panels/dock/tray/trayitempositionmanager.cpp +++ b/panels/dock/tray/trayitempositionmanager.cpp @@ -139,8 +139,15 @@ TrayItemPositionManager::TrayItemPositionManager(QObject *parent) connect(this, &TrayItemPositionManager::visualItemCountChanged, this, &TrayItemPositionManager::updateVisualSize); + // Use QueuedConnection for dockHeightChanged to break a synchronous + // signal/slot cascade that causes "Binding loop for dockItemMaxSize". + // When dockSize changes (e.g. during drag), dockHeightChanged fires + // synchronously, calling updateVisualSize -> visualSizeChanged, which + // marks dockItemMaxSize dirty (it transitively reads visualSize via + // dockRawCenterSpace -> dockRightPart -> tray). Queuing the slot lets + // the current binding evaluation finish before visualSize updates. connect(this, &TrayItemPositionManager::dockHeightChanged, - this, &TrayItemPositionManager::updateVisualSize); + this, &TrayItemPositionManager::updateVisualSize, Qt::QueuedConnection); connect(this, &TrayItemPositionManager::orientationChanged, this, &TrayItemPositionManager::updateVisualSize); connect(this, &TrayItemPositionManager::visualItemSizeChanged, diff --git a/panels/dock/tray/trayitempositionmanager.h b/panels/dock/tray/trayitempositionmanager.h index da1c89cd0..dfc436dcb 100644 --- a/panels/dock/tray/trayitempositionmanager.h +++ b/panels/dock/tray/trayitempositionmanager.h @@ -15,7 +15,7 @@ struct DropIndex { Q_PROPERTY(int index MEMBER index) Q_PROPERTY(bool isOnItem MEMBER isOnItem) Q_PROPERTY(bool isBefore MEMBER isBefore) - QML_ELEMENT + QML_NAMED_ELEMENT(dropIndex) public: int index; bool isOnItem = true; diff --git a/panels/notification/center/OverlapNotify.qml b/panels/notification/center/OverlapNotify.qml index ba674931b..3c20a5f81 100644 --- a/panels/notification/center/OverlapNotify.qml +++ b/panels/notification/center/OverlapNotify.qml @@ -143,7 +143,7 @@ NotifyItem { OverlapIndicator { id: indicator - enableAnimation: root.ListView.view.panelShown + enableAnimation: (root.ListView.view && root.ListView.view.panelShown) ?? false clipItems: true anchors { bottom: parent.bottom