Repository navigation
Conversation
…rarily unreadable common/dconfig Bool.Get() silently returned false when the dconfig backend was temporarily unreadable (daemon startup race, service restart, bus congestion), and the touchpad apply functions wrote that value unconditionally. A single re-apply inside such a window reset Tapping/NaturalScroll/DisableWhileTyping to 0 and collapsed the mutually-exclusive scroll method bits to 0,0,0, breaking tap-to-click and two-finger scrolling while dconfig still held true. - common/dconfig: Bool keeps a last-known-good value, adds GetWithError() so callers can tell 'configured false' from unreadable - inputdevices1: touchpad apply functions skip the apply and log a warning when the config read fails, leaving device properties intact Log: dconfig 暂时不可读时触摸板设置被整体写为 false/零值,轻点与双指滚动失效 Fixes: linuxdeepin#1270
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hualet 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 GuideThe PR prevents transient dconfig read failures from clearing touchpad settings by caching the last known boolean values, skipping affected applies when reads fail, and surfacing both configuration and device-application failures through warnings while preserving normal readable-path behavior. Sequence diagram for safe touchpad settings applicationsequenceDiagram
participant Touchpad
participant Bool
participant DConfig
participant XDevice
participant Logger
Touchpad->>Bool: GetWithError()
Bool->>DConfig: GetValueBool(key)
alt dconfig readable
DConfig-->>Bool: value, nil
Bool-->>Touchpad: value, nil
Touchpad->>XDevice: EnableTapToClick(value)
XDevice-->>Touchpad: success or error
opt device apply error
Touchpad->>Logger: Warningf(...)
end
else dconfig temporarily unreadable
DConfig-->>Bool: lastKnown, error
Bool-->>Touchpad: lastKnown, error
Touchpad->>Logger: Warningf(...)
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ❌评价: 一般 ❌ 不通过 潜在问题:
建议: 1.将 enableLeftHanded() 也改为使用 GetWithError() 并在错误时跳过应用 2. 代码质量 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 可考虑提取一个 applyBoolSetting(val *dconfig.Bool, applyFn func(bool) error, settingName string) 辅助函数来统一处理错误检查和应用逻辑,减少重复代码 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,互斥锁使用正确,lastKnown 缓存避免了 dconfig 不可读时的冗余读取 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 本次变更无安全风险,变更内容仅涉及配置读取错误处理逻辑,不涉及用户输入处理、命令执行或权限操作 💡 改进建议代码示例// 修复 enableLeftHanded 遗漏
func (tpad *Touchpad) enableLeftHanded() {
enabled, err := tpad.LeftHanded.GetWithError()
if err != nil {
logger.Warningf("skip left-handed apply, dconfig unreadable: %v", err)
return
}
for _, v := range tpad.devInfos {
err := v.EnableLeftHanded(enabled)
if err != nil {
logger.Warningf("Enable left handed '%v - %v' failed: %v",
v.Id, v.Name, err)
}
}
}
// 修复 Set() 中 lastKnown 缓存一致性(可选)
func (b *Bool) Set(val bool) bool {
if b.Get() != val {
b.mu.Lock()
defer b.mu.Unlock()
err := b.dc.SetValue(b.key, val)
if err == nil {
b.lastKnown = val
}
return err == nil
}
return true
}本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.1.108 |
|
TAG Bot New tag: 6.1.109 |
|
TAG Bot New tag: 6.1.110 |
|
TAG Bot New tag: 6.1.111 |
Fixes #1270
问题
common/dconfig/dcprop.go的Bool.Get()在 dconfig 后端暂时不可读(dde-dconfig-daemon 开机激活竞态、服务重启、总线拥塞)时静默返回 false,inputdevices1/touchpad.go的 apply 函数又把这个值无条件写入 X 设备属性。一次读失败窗口内的重应用会把触摸板设置整体清零:而此时 dconfig 中对应键值实际全部为 true,表现为轻点点击与双指滚动失效,且 apply 失败只有 Debugf 日志,生产环境不可见。
修改
common/dconfig/dcprop.go:Bool保留最近一次成功读取值(lastKnown),新增GetWithError() (bool, error)——读失败返回缓存值及错误,调用方可区分"配置就是 false"与"值读不到";Get()基于其实现;inputdevices1/touchpad.go:enableTapToClick/enableNaturalScroll/enableEdgeScroll/enableTwoFingerScroll/disableWhileTyping/enablePalmDetect改用GetWithError,读失败时跳过本次应用(设备属性保持现状)并记 Warning;apply 失败日志 Debugf → Warningf。不改变任何正常路径的行为:dconfig 可读时应用逻辑与之前完全一致。
验证
Summary by Sourcery
Preserve touchpad state during transient dconfig read failures while maintaining existing behavior when configuration is available.
Bug Fixes:
Enhancements: