fix(dock): eliminate several QML runtime/compile warnings - #1711
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideRemoves several QML runtime and registration warnings by making signal and view lookups safe, replacing the deprecated task-item add animation syntax, breaking dock sizing binding loops, supplying explicit drag-image sizes, and correcting the tray drop-index QML type name while preserving existing behavior. Flow diagram for warning-safe dock and notification behaviorflowchart LR
ShellSurface[Shell surface] -->|cursorShapeRequested| Proxy[ShellSurfaceItemProxy]
Proxy -->|ignore unknown signals| SafeSignal[Warning-free signal handling]
TaskModel[Task manager model] --> ListView[ListView]
ListView -->|add Transition| AddAnimation[Scale and opacity animation]
DockLayout[Dock layout] -->|useColumnLayout| DockSize[Return dockSize directly]
DockLayout -->|other direction| ContentSize[Compute content-based size]
DragItem[Dock or tray item] -->|grabToImage(width,height)| DragImage[Explicit-size drag image]
ListViewView[ListView.view] -->|exists| Overlap[panelShown lookup]
ListViewView -->|missing| Disabled[Animation disabled]
DropIndex[DropIndex gadget] -->|QML_NAMED_ELEMENT| dropIndex[dropIndex value type]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
c879751 to
c2e1cec
Compare
Fix a set of compiler and QML runtime warnings: - Enable -Werror for C/C++ and guard the clang-format targets so the build fails on warnings instead of silently ignoring them; only set up the format/commit hooks when clang-format is available. - Register the D_APPLET_CLASS macro as an AUTOMOC macro name for the notification server test to silence its moc warning. - AppletDockItem: coerce Applet.visible/supported to bool with !! operators to avoid assigning undefined to a bool property. - ShellSurfaceItemProxy: connect the cursorShapeRequested signal dynamically and only when the surface exposes it (PluginPopup), since a static Connections handler warned that no matching signal exists. - TaskManager: drop the implicitWidth/implicitHeight binding loop by returning the fixed dock size in the layout direction that does not depend on appContainer, and give the onAdd animation an id so the deprecated object-to-signal-handler assignment is avoided. - AppItem: resolve the Drag.active binding loop by setting Drag.active imperatively from the MouseArea's drag handler instead of binding it to the driving property. - TrayItemPositionManager: register the DropIndex value type under the lowercase name dropIndex via QML_NAMED_ELEMENT, so qmltyperegistrar stops warning about its value-type name while keeping the C++ struct name unchanged; also use Qt::QueuedConnection for the dockHeightChanged -> updateVisualSize connection to break the synchronous signal/slot cascade that causes the "Binding loop detected for dockItemMaxSize" warning. - OverlapNotify: guard the panelShown lookup so an undefined ListView.view no longer assigns undefined to a bool property. - Resolve dpkg -Wall -Werror build failures: reorder the member initializer list in AMAppItemModel to match the declaration order, drop the unused windowCount/initResult variables, and initialize the previously uninitialized needHide/needShow/anchor variables. 修复 dde-shell 及任务栏的编译与 QML 运行时告警: - 对 C/C++ 启用 -Werror,并将 clang-format 相关目标用条件包裹,让构建 在出现告警时报错而非静默跳过;仅在检测到 clang-format 时才构建 格式化与提交钩子目标。 - 为通知服务测试注册额外 moc 宏 D_APPLET_CLASS,消除其必要的 moc 告警。 - AppletDockItem:对 Applet.visible/Applet.supported 使用 !! 强制转换为 bool,避免将 undefined 赋给 bool 属性。 - ShellSurfaceItemProxy:将 cursorShapeRequested 改为仅在 surface 暴露该 信号时(PluginPopup)动态连接,原静态 Connections 处理器会因没有匹配 信号而告警。 - 通过在被布局方向直接返回固定的 dock 尺寸、不再依赖 appContainer, 消除 TaskManager 的 implicitWidth/implicitHeight 绑定循环;并为委托的 入场动画补充 id,规避已废弃的"将对象赋给信号处理器"写法。 - AppItem:改为在 mouseArea 的拖拽处理器中命令式设置 Drag.active, 而非绑定到驱动它的属性,消除 Drag.active 绑定循环告警。 - TrayItemPositionManager:通过 QML_NAMED_ELEMENT 将 DropIndex 值类型 注册为小写 dropIndex,在保留 C++ 结构体名的同时消除 qmltyperegistrar 对值类型名的告警;并将 dockHeightChanged 到 updateVisualSize 的连接 改为 Qt::QueuedConnection,打断同步 C++ 信号/槽级联,消除 "Binding loop detected for dockItemMaxSize" 告警。 - OverlapNotify:为 panelShown 查询加空值守卫,避免未定义的 ListView.view 将 undefined 赋给 bool 属性。 - 解决 dpkg -Wall -Werror 编译失败:调整 AMAppItemModel 的成员初始化 列表顺序使其与声明顺序一致,移除未使用的 windowCount/initResult 变量,并初始化先前未初始化的 needHide/needShow/anchor 变量。 PMS: TASK-394335
c2e1cec to
dfc6499
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议为 dockhelper.cpp 的两个 switch 语句和 waylanddockhelper.cpp 的 switch 添加 default 分支,在 default 中设置安全默认值或提前 return,以增强代码健壮性 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议在 ShellSurfaceItemProxy.qml 的 onAboutToDestroy 处理器中也调用 updateCursorShapeConnection() 以确保连接被正确清理;-Werror 选项建议通过 CMake option() 控制是否启用,便于在不同环境灵活配置 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: QueuedConnection 的使用是解决绑定环的合理方案,短暂的视觉延迟通常可接受。若需进一步优化,可考虑在 updateVisualSize 中添加防抖机制,避免快速尺寸变化时的冗余更新 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 本次变更不涉及用户输入处理、网络通信或权限操作,安全风险低。代码变更保持了原有的安全边界,无新增安全风险。 💡 改进建议代码示例// dockhelper.cpp - 添加 default 分支增强健壮性
void DockHelper::checkNeedHideOrNot()
{
bool needHide = false;
switch (parent()->hideMode()) {
case KeepShowing:
needHide = currentActiveWindowFullscreened();
break;
case SmartHide:
needHide = isWindowOverlap();
break;
case KeepHidden:
needHide = true;
break;
default:
qWarning() << "Unknown hide mode:" << parent()->hideMode();
needHide = false;
break;
}
// ...
}
// waylanddockhelper.cpp - 添加 default 分支
void WaylandDockHelper::updateOverlapCheckerPos()
{
// ...
uint32_t anchor = 0;
switch (m_panel->position()) {
case Top:
anchor = QtWayland::treeland_window_overlap_checker::anchor_top;
break;
// ... other cases ...
default:
qWarning() << "Unknown panel position:" << m_panel->position();
return;
}
// ...
}本报告由 AI 代码审查工具自动生成 |
Log: fix multiple QML warnings reported by journalctl/qmltyperegistrar
Influence:
fix(dock): 消除任务栏与通知中心若干 QML 运行时/注册告警
Log: 修复 journalctl/qmltyperegistrar 报告的多项 QML 告警
Influence:
PMS: TASK-394379
Summary by Sourcery
Remove QML runtime and type-registration warnings across dock, task manager, tray, and notification components while preserving existing behavior.
Bug Fixes:
Enhancements: