Commit daacc03
committed
fix: prevent crashes from dangling pointers in destructors
1. Fixed null pointer dereference in
DQuickWindowAttachedPrivate::destoryPlatformHandle() by adding null
check before calling setEnabledNoTitlebarForWindow
2. Fixed event filter in DQuickWindowAttached to use window() instead of
parent() to avoid accessing destroyed parent object
3. Added null check for window in
DQuickWindowAttached::setAlphaBufferSize() to prevent accessing
destroyed window
4. Added null checks in DQuickControlColorSelector palette handling to
prevent crashes when items are destroyed
5. Added connection to QObject::destroyed signal to clear control and
window pointers when control is destroyed
6. Changed m_control and m_controlWindow from raw pointers to QPointer
for automatic nullification
7. Changed DQuickWindowAttachedPrivate::window from raw pointer to
QPointer to prevent dangling pointer access
Log: Fixed crashes caused by accessing destroyed objects during window
and palette cleanup
Influence:
1. Test window destruction scenarios to ensure no crashes occur
2. Verify palette functionality still works correctly with valid
controls
3. Test window resize and minimize operations after palette changes
4. Verify alpha buffer size setting works with valid windows
5. Test rapid creation and destruction of windows with custom palettes
6. Verify no memory leaks occur with repeated window creation/
destruction
fix: 修复析构导致的野指针崩溃问题
1. 在 DQuickWindowAttachedPrivate::destoryPlatformHandle() 中添加空指针
检查,避免在调用 setEnabledNoTitlebarForWindow 时访问已销毁对象
2. 修复 DQuickWindowAttached 中的事件过滤器,使用 window() 替代 parent()
避免访问已销毁的父对象
3. 在 DQuickWindowAttached::setAlphaBufferSize() 中添加窗口空指针检查,
防止访问已销毁的窗口
4. 在 DQuickControlColorSelector 调色板处理中添加空指针检查,防止控件销
毁时崩溃
5. 添加 QObject::destroyed 信号连接,在控件销毁时清除控制和窗口指针
6. 将 m_control 和 m_controlWindow 从原始指针改为 QPointer,实现自动置空
7. 将 DQuickWindowAttachedPrivate::window 从原始指针改为 QPointer,防止
悬垂指针访问
Log: 修复了窗口和调色板清理过程中访问已销毁对象导致的崩溃问题
Influence:
1. 测试窗口销毁场景,确保不会发生崩溃
2. 验证调色板功能在有效控件下仍能正常工作
3. 测试窗口调整大小和最小化操作后的调色板变化
4. 验证 alpha 缓冲区大小设置在有效窗口下正常工作
5. 测试快速创建和销毁带有自定义调色板的窗口
6. 验证重复窗口创建/销毁不会导致内存泄漏1 parent 1aa2c93 commit daacc03
4 files changed
Lines changed: 25 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
| 177 | + | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
| |||
1025 | 1026 | | |
1026 | 1027 | | |
1027 | 1028 | | |
1028 | | - | |
| 1029 | + | |
1029 | 1030 | | |
1030 | 1031 | | |
1031 | 1032 | | |
| |||
1045 | 1046 | | |
1046 | 1047 | | |
1047 | 1048 | | |
| 1049 | + | |
| 1050 | + | |
1048 | 1051 | | |
1049 | 1052 | | |
1050 | 1053 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | | - | |
| 75 | + | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| |||
467 | 471 | | |
468 | 472 | | |
469 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
470 | 478 | | |
471 | 479 | | |
472 | 480 | | |
| |||
1086 | 1094 | | |
1087 | 1095 | | |
1088 | 1096 | | |
1089 | | - | |
| 1097 | + | |
| 1098 | + | |
1090 | 1099 | | |
1091 | 1100 | | |
1092 | 1101 | | |
1093 | 1102 | | |
1094 | | - | |
| 1103 | + | |
1095 | 1104 | | |
1096 | 1105 | | |
1097 | 1106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
374 | | - | |
| 373 | + | |
| 374 | + | |
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | | - | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
0 commit comments