Skip to content

Commit 7db1c24

Browse files
committed
fix: prevent DBus signal infinite loop in QML bindings
Added conditional checks before calling DBus setter methods in all Switch components to avoid infinite signal loops. Previously, when a Switch's checked property changed, it would immediately call the corresponding DBus setter method, which would emit a signal that updates the model property, causing the Switch's checked property to update again, creating an infinite loop. Now each onCheckedChanged handler checks if the new checked value differs from the current model value before calling the setter, breaking the circular dependency. Log: Fixed potential UI freezes caused by infinite signal loops in update settings Influence: 1. Test all toggle switches in update settings: function updates, security updates, third-party updates 2. Verify download speed limit toggle works correctly 3. Test auto-download updates toggle functionality fix: 修复 QML 绑定中 DBus 信号无限循环问题 在所有 Switch 组件中调用 DBus setter 方法前添加条件检查,避免无限信号 循环。之前,当 Switch 的 checked 属性发生变化时,会立即调 用相应的 DBus setter 方法,这会发出更新模型属性的信号,导致 Switch 的 checked 属性再次更新,形成无限循环。现在每个 onCheckedChanged 处理程序 在调用 setter 之前检查新的 checked 值是否与当前模型值不同,从而打破循环 依赖。 Log: 修复了更新设置中无限信号循环可能导致的界面冻结问题 Influence: 1. 测试更新设置中的所有切换开关:功能更新、安全更新、第三方更新 2. 验证下载速度限制开关正常工作 3. 测试自动下载更新开关功能 PMS: BUG-354897 Change-Id: Id7969f3fdf0dd052494857ef6857f0f75426db56
1 parent cbdecb2 commit 7db1c24

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

src/dcc-update-plugin/qml/UpdateSetting.qml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ DccObject {
5252
page: D.Switch {
5353
checked: dccData.model().functionUpdate
5454
onCheckedChanged: {
55-
dccData.work().setFunctionUpdate(checked)
55+
if (checked !== dccData.model().functionUpdate) {
56+
dccData.work().setFunctionUpdate(checked)
57+
}
5658
}
5759
}
5860
}
@@ -68,7 +70,9 @@ DccObject {
6870
page: D.Switch {
6971
checked: dccData.model().securityUpdate
7072
onCheckedChanged: {
71-
dccData.work().setSecurityUpdate(checked)
73+
if (checked !== dccData.model().securityUpdate) {
74+
dccData.work().setSecurityUpdate(checked)
75+
}
7276
}
7377
}
7478
}
@@ -84,7 +88,9 @@ DccObject {
8488
page: D.Switch {
8589
checked: dccData.model().thirdPartyUpdate
8690
onCheckedChanged: {
87-
dccData.work().setThirdPartyUpdate(checked)
91+
if (checked !== dccData.model().thirdPartyUpdate) {
92+
dccData.work().setThirdPartyUpdate(checked)
93+
}
8894
}
8995
}
9096
}
@@ -183,7 +189,9 @@ DccObject {
183189
page: D.Switch {
184190
checked: dccData.model().downloadSpeedLimitEnabled
185191
onCheckedChanged: {
186-
dccData.work().setDownloadSpeedLimitEnabled(checked)
192+
if (checked !== dccData.model().downloadSpeedLimitEnabled) {
193+
dccData.work().setDownloadSpeedLimitEnabled(checked)
194+
}
187195
}
188196
}
189197
}
@@ -256,7 +264,9 @@ DccObject {
256264
page: D.Switch {
257265
checked: dccData.model().autoDownloadUpdates
258266
onCheckedChanged: {
259-
dccData.work().setAutoDownloadUpdates(checked)
267+
if (checked !== dccData.model().autoDownloadUpdates) {
268+
dccData.work().setAutoDownloadUpdates(checked)
269+
}
260270
}
261271
}
262272
}
@@ -286,7 +296,9 @@ DccObject {
286296
return dccData.model().idleDownloadEnabled
287297
}
288298
onCheckedChanged: {
289-
dccData.work().setIdleDownloadEnabled(checked)
299+
if (checked !== dccData.model().idleDownloadEnabled) {
300+
dccData.work().setIdleDownloadEnabled(checked)
301+
}
290302
}
291303
}
292304

@@ -352,7 +364,9 @@ DccObject {
352364
page: D.Switch {
353365
checked: dccData.model().updateNotify
354366
onCheckedChanged: {
355-
dccData.work().setUpdateNotify(checked)
367+
if (checked !== dccData.model().updateNotify) {
368+
dccData.work().setUpdateNotify(checked)
369+
}
356370
}
357371
}
358372
}
@@ -366,7 +380,9 @@ DccObject {
366380
page: D.Switch {
367381
checked: dccData.model().autoCleanCache
368382
onCheckedChanged: {
369-
dccData.work().setAutoCleanCache(checked)
383+
if (checked !== dccData.model().autoCleanCache) {
384+
dccData.work().setAutoCleanCache(checked)
385+
}
370386
}
371387
}
372388
}
@@ -423,7 +439,9 @@ DccObject {
423439
page: D.Switch {
424440
checked: dccData.model().smartMirrorSwitch
425441
onCheckedChanged: {
426-
dccData.work().setSmartMirror(checked)
442+
if (checked !== dccData.model().smartMirrorSwitch) {
443+
dccData.work().setSmartMirror(checked)
444+
}
427445
}
428446
}
429447
}

0 commit comments

Comments
 (0)