fix: resolve AlertToolTip parent binding loop - #668
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 52cyb 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 guide (collapsed on small PRs)Reviewer's GuideThis PR fixes a QML binding loop warning in AlertToolTip by replacing a declarative parent binding with an imperative update function that is invoked on component completion and when the shown state changes, preserving existing z-order and drag behavior while breaking the cyclic dependency. Flow diagram for AlertToolTip parent update logicflowchart TD
A[_shown changes or component completed] --> B[_updateParent]
B --> C{_shown?}
C -->|true| D[set parent = Overlay.overlay]
C -->|false| E[set parent = target]
D --> F[parent no longer bound declaratively]
E --> F[parent no longer bound declaratively]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
f63645c to
4928f02
Compare
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- If
parentshould also react to changes intarget(not only_shown), consider invoking_updateParent()from theonTargetChangedhandler as well to keep the parent consistent. - Double-check that
on_ShownChangedmatches the actual property name (_shownvsshown) and QML signal naming conventions (e.g.onShownChanged), to ensure the handler is actually triggered.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- If `parent` should also react to changes in `target` (not only `_shown`), consider invoking `_updateParent()` from the `onTargetChanged` handler as well to keep the parent consistent.
- Double-check that `on_ShownChanged` matches the actual property name (`_shown` vs `shown`) and QML signal naming conventions (e.g. `onShownChanged`), to ensure the handler is actually triggered.
## Individual Comments
### Comment 1
<location path="qt6/src/qml/AlertToolTip.qml" line_range="33-37" />
<code_context>
NumberAnimation { duration: 200 }
}
- parent: _shown ? Overlay.overlay : target
+ function _updateParent() {
+ parent = _shown ? Overlay.overlay : target
+ }
+ Component.onCompleted: _updateParent()
+ on_ShownChanged: _updateParent()
opacity: _shown ? 1 : 0
enabled: _shown
</code_context>
<issue_to_address>
**issue (bug_risk):** Parent is no longer reactive to `target` or `Overlay.overlay` changes, unlike the original binding.
By turning `parent: _shown ? Overlay.overlay : target` into `_updateParent()` that only runs on `Component.onCompleted` and `_shown` changes, `parent` no longer reacts to `target` or `Overlay.overlay` updates. If either can change at runtime, the item will end up parented incorrectly. Please ensure `_updateParent()` is also triggered when `target` or `Overlay.overlay` change, or reintroduce a binding-like mechanism (e.g. `Binding` or additional change handlers).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
4928f02 to
e9244f2
Compare
e9244f2 to
0942490
Compare
0942490 to
d3a7812
Compare
1. Replace declarative parent binding with imperative assignment to break the parent/Overlay.overlay/window dependency cycle 2. Add _updateParent() function invoked via on_ShownChanged and Component.onCompleted to keep parent in sync 3. Preserves z-order and drag-fix semantics from prior commits (c9a9274, dc000a4) Influence: 1. Verify alert tooltip appears correctly above edit controls 2. Confirm show/hide cycle emits no binding loop warning 3. Verify tooltip parent returns to target when hidden fix: 修复 AlertToolTip parent 绑定循环 1. 将声明式 parent 绑定改为命令式赋值,打破 parent/Overlay.overlay/window 依赖环 2. 新增 _updateParent() 函数,通过 on_ShownChanged 和 Component.onCompleted 调用以保持 parent 同步 3. 保留此前提交的 z-order 与拖动修复语义 (c9a9274, dc000a4) Influence: 1. 验证告警提示框在编辑控件上方正确显示 2. 确认显示/隐藏循环不再产生 binding loop 警告 3. 验证隐藏时 tooltip 父级正确回到 target PMS: TASK-392413
d3a7812 to
840f29e
Compare
修复 AlertToolTip parent binding loop
问题
控制中心-账户-用户组设置,新建/编辑用户组出现错误 Alert 时,QML 报出 binding loop 警告:
根因
qt6/src/qml/AlertToolTip.qml第 33 行声明式绑定parent: _shown ? Overlay.overlay : target形成自引用依赖环:parent→Overlay.overlay→window→parent每次 alert 显示/隐藏时反复重父,触发 Qt binding loop 检测。
修复
将
parent从声明式绑定改为命令式赋值:_updateParent()函数Component.onCompleted和on_ShownChanged调用parent ↔ Overlay.overlay ↔ window循环依赖改动文件
qt6/src/qml/AlertToolTip.qml(+5/-1)验证
PMS 任务
PMS TASK-392413
Multica Issue
DDE-145
Summary by Sourcery
Bug Fixes: