Skip to content

Commit 5261658

Browse files
caixr23lzwind
authored andcommitted
fix: prevent crash from RequestConfigFinished signal connection
Changed the signal connection from lambda in Component.onCompleted to proper Connections component. The previous approach using a lambda directly connected to the signal could cause crashes when the component was destroyed, as the lambda might outlive the QML context or create dangling references. Using the Connections component ensures proper lifecycle management and automatic disconnection when the component is destroyed. Influence: 1. Test opening and closing detail configuration pages multiple times 2. Verify no crash occurs when rapidly switching between different configuration items 3. Test memory stability during extended usage of the configuration tool 4. Verify signal disconnection works correctly when components are destroyed 5. Test that globalConfigOptions are properly refreshed when RequestConfigFinished is emitted fix: 修复 RequestConfigFinished 信号导致崩溃的问题 将信号连接方式从 Component.onCompleted 中的 lambda 改为使用 Connections 组件。之前直接在信号上连接 lambda 的方式可能在组件销毁时导致崩溃,因为 lambda 可能超出 QML 上下文的生命周期或产生悬空引用。使用 Connections 组 件可以确保正确的生命周期管理,并在组件销毁时自动断开连接。 Influence: 1. 测试多次打开和关闭详细配置页面 2. 验证在不同配置项之间快速切换时不会发生崩溃 3. 测试配置工具长时间使用时的内存稳定性 4. 验证组件销毁时信号断开连接是否正常工作 5. 测试 RequestConfigFinished 发出时 globalConfigOptions 是否正确刷新
1 parent 4f54c90 commit 5261658

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/dcc-fcitx5configtool/qml/DetailConfigItem.qml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,16 @@ DccObject {
190190
}
191191
}
192192
}
193+
Connections {
194+
target: dccData.fcitx5ConfigProxy
195+
function onRequestConfigFinished() {
196+
configOptions = []
197+
configOptions = dccData.fcitx5ConfigProxy.globalConfigOptions(root.name)
198+
keyName = ""
199+
}
200+
}
193201

194202
Component.onCompleted: {
195-
dccData.fcitx5ConfigProxy.onRequestConfigFinished.connect(() => {
196-
configOptions = []
197-
configOptions = dccData.fcitx5ConfigProxy.globalConfigOptions(
198-
root.name)
199-
keyName = ""
200-
})
201203
configOptions = dccData.fcitx5ConfigProxy.globalConfigOptions(root.name)
202204
loading = false
203205
}

0 commit comments

Comments
 (0)