Commit 1cd2097
committed
fix: change signal context to prevent dangling pointer
Changed the context parameter in QObject::connect from 'this' to
'deviceItem' for the Device::pairedChanged signal connection. This
prevents potential dangling pointer issues when the deviceItem object
is deleted while signals are still being processed. The original code
used 'this' as context, which could lead to accessing invalid memory if
deviceItem was destroyed before the slot execution.
Influence:
1. Test Bluetooth device pairing state changes
2. Verify device removal and addition scenarios
3. Check memory usage and stability during device operations
4. Test with multiple Bluetooth adapters and devices
5. Verify no crashes occur when devices are disconnected or removed
fix: 更改信号上下文以防止野指针问题
将 QObject::connect 中 Device::pairedChanged 信号的上下文参数从 'this'
改为 'deviceItem'。这可以防止当 deviceItem 对象被删除而信号仍在处理时可
能出现的野指针问题。原始代码使用 'this' 作为上下文,如果 deviceItem 在槽
函数执行前被销毁,可能导致访问无效内存。
Influence:
1. 测试蓝牙设备配对状态变化
2. 验证设备移除和添加场景
3. 检查设备操作期间的内存使用和稳定性
4. 测试多个蓝牙适配器和设备
5. 验证设备断开或移除时不会发生崩溃
PMS: BUG-3508591 parent 352f45f commit 1cd2097
1 file changed
Lines changed: 2 additions & 2 deletions
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| |||
0 commit comments