fix(display): prevent unintended brightness reset to 10%#2993
fix(display): prevent unintended brightness reset to 10%#2993deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the display brightness slider behavior so that backend brightness is updated only on explicit user interaction, preventing unintended resets to 10% and avoiding a race condition during object destruction. Sequence diagram for explicit brightness update via slider movementsequenceDiagram
actor User
participant BrightnessSlider
participant DisplayScreenItem
participant BackendCPlusPlus
User->>BrightnessSlider: drag handle
BrightnessSlider->>BrightnessSlider: onMoved(value)
BrightnessSlider->>DisplayScreenItem: set brightness(value)
DisplayScreenItem->>BackendCPlusPlus: updateBrightness(value)
rect rgb(240,240,240)
User-->>BrightnessSlider: no interaction
BackendCPlusPlus->>DisplayScreenItem: set brightness(programmaticValue)
DisplayScreenItem->>BrightnessSlider: value = programmaticValue
BrightnessSlider--xDisplayScreenItem: onMoved not triggered
DisplayScreenItem-->>BackendCPlusPlus: brightness not overwritten
end
rect rgb(230,230,255)
BackendCPlusPlus-->>DisplayScreenItem: begin destruction
DisplayScreenItem-->>BrightnessSlider: internal value correction to 0.1
BrightnessSlider--xBackendCPlusPlus: onMoved not called, no write-back
BackendCPlusPlus-->>BackendCPlusPlus: stored brightness preserved
end
Flow diagram for brightness update logic from sliderflowchart TD
A[User moves brightness slider handle] --> B[BrightnessSlider onMoved handler]
B --> C[Set DisplayScreenItem brightness to slider value]
C --> D[BackendCPlusPlus updateBrightness invoked]
D --> E[Persisted brightness updated]
F[Programmatic change to brightness value] --> G[DisplayScreenItem sets slider value]
G --> H[BrightnessSlider onMoved not triggered]
H --> I[BackendCPlusPlus brightness not overwritten]
J[Object destruction or internal slider correction to 0.1] --> K[Slider value updated internally]
K --> L[No onMoved callback]
L --> M[Stored brightness preserved, no reset to 10 percent]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这段代码主要修改了 QML 中 Slider 组件的信号处理逻辑,将 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与建议这次修改在逻辑清晰度和代码质量上是很好的优化,避免了双向绑定的潜在复杂性。 关键建议:
// 备选方案:兼容拖动和其他输入方式
onValueChanged: {
// 只有当值确实不同时才更新,防止循环
if (screenItem.brightness !== value) {
screenItem.brightness = value
}
}或者,如果是为了解决性能问题(拖动时频繁触发),可以使用 |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Switching from
onValueChangedtoonMovedmeans brightness updates will no longer occur for non-pointer interactions (e.g., keyboard, accessibility tools, or programmatic slider changes); consider whether those paths still need to updatescreenItem.brightnessand if so handle them explicitly. - If
screenItem.brightnesscan change externally while the slider is visible, it may now drift out of sync with the slider’s visual state; consider whether a binding or explicit synchronization is still required in those scenarios.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Switching from `onValueChanged` to `onMoved` means brightness updates will no longer occur for non-pointer interactions (e.g., keyboard, accessibility tools, or programmatic slider changes); consider whether those paths still need to update `screenItem.brightness` and if so handle them explicitly.
- If `screenItem.brightness` can change externally while the slider is visible, it may now drift out of sync with the slider’s visual state; consider whether a binding or explicit synchronization is still required in those scenarios.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- Replace onValueChanged with onMoved for brightness slider to ensure backend values are only updated by explicit user interaction. - Fix a race condition where slider auto-correction (to 'from' value 0.1) would overwrite C++ data during object destruction. Pms: BUG-308187 BUG-307119 Log: prevent unintended brightness reset to 10% Signed-off-by: ComixHe <heyuming@deepin.org>
|
/forcemerge |
|
This pr force merged! (status: blocked) |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, ComixHe 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 |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, ComixHe 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 |
Pms: BUG-308187 BUG-307119
Log: prevent unintended brightness reset to 10%
Summary by Sourcery
Bug Fixes: