Commit 2d49c07
fix: replace QScopedPointer with raw pointer for DSGConfigManager
1. Changed DBusBackend::config from QScopedPointer<DSGConfigManager> to
raw pointer DSGConfigManager*
2. Initialize config to nullptr in constructor initializer list
3. Replace config.reset(new DSGConfigManager(...)) with direct new
operator
4. Replace config.reset() with config->deleteLater() and config =
nullptr in error handling
5. Replace config.data() with config in QObject::connect call
6. This eliminates redundant ownership management since DSGConfigManager
is already a QObject with its own lifetime management
Log: Fixed potential double deletion issue with DSGConfigManager object
Influence:
1. Test DConfig functionality with DBus backend to ensure no memory
leaks
2. Verify that valueChanged signals are still properly connected and
emitted
3. Test error scenarios where DSGConfigManager creation fails
4. Verify object cleanup when DConfig is destroyed
5. Test with multiple DConfig instances to ensure no interference
fix: 将 DSGConfigManager 的 QScopedPointer 替换为原始指针
1. 将 DBusBackend::config 从 QScopedPointer<DSGConfigManager> 改为原始指
针 DSGConfigManager*
2. 在构造函数初始化列表中初始化 config 为 nullptr
3. 将 config.reset(new DSGConfigManager(...)) 替换为直接使用 new 操作符
4. 在错误处理中将 config.reset() 替换为 config->deleteLater() 和 config
= nullptr
5. 在 QObject::connect 调用中将 config.data() 替换为 config
6. 消除了重复的所有权管理,因为 DSGConfigManager 已经是具有自身生命周期
管理的 QObject
Log: 修复了 DSGConfigManager 对象可能被重复删除的问题
Influence:
1. 测试使用 DBus 后端的 DConfig 功能,确保没有内存泄漏
2. 验证 valueChanged 信号是否仍然正确连接和发射
3. 测试 DSGConfigManager 创建失败的场景
4. 验证 DConfig 销毁时的对象清理
5. 测试多个 DConfig 实例以确保没有相互干扰
PMS: BUG-3358811 parent faab807 commit 2d49c07
1 file changed
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| |||
345 | 346 | | |
346 | 347 | | |
347 | 348 | | |
348 | | - | |
349 | | - | |
| 349 | + | |
| 350 | + | |
350 | 351 | | |
351 | 352 | | |
352 | | - | |
| 353 | + | |
| 354 | + | |
353 | 355 | | |
354 | 356 | | |
355 | | - | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
| |||
456 | 458 | | |
457 | 459 | | |
458 | 460 | | |
459 | | - | |
| 461 | + | |
460 | 462 | | |
461 | 463 | | |
462 | 464 | | |
| |||
0 commit comments