Commit 87b7184
committed
fix: replace raw pointers with QPointer to prevent wild pointers
Changed raw QWaylandSurface pointers to QPointer smart pointers in
PluginManagerExtensionPrivate and PluginManagerExtension classes to
prevent wild pointer issues. This ensures automatic nullification when
the referenced QWaylandSurface objects are destroyed, preventing crashes
and undefined behavior.
The raw pointers were vulnerable to becoming wild pointers if the
QWaylandSurface objects were deleted while still being referenced. Using
QPointer provides safe weak referencing with automatic null checks,
improving memory safety and stability.
Influence:
1. Test plugin management functionality with dynamic surface creation
and destruction
2. Verify no crashes occur when surfaces are removed while being
referenced
3. Test docking panel behavior with multiple plugin instances
4. Validate memory safety during compositor operations
5. Check for any regression in plugin loading/unloading
fix: 使用 QPointer 替换原始指针以防止野指针问题
将 PluginManagerExtensionPrivate 和 PluginManagerExtension 类中的原始
QWaylandSurface 指针替换为 QPointer 智能指针,以防止野指针问题。这确保当
引用的 QWaylandSurface 对象被销毁时自动置空,防止崩溃和未定义行为。
原始指针在引用的 QWaylandSurface 对象被删除时容易变成野指针。使用
QPointer 提供安全的弱引用和自动空值检查,提高了内存安全性和稳定性。
```
#0 0x00007f906aeedae6 in QList<QWaylandView*>::size (this=<optimized out>) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qlist.h:399
#1 QtPrivate::indexOf<QWaylandView*, QWaylandView*> (from=<optimized out>, u=<optimized out>, vector=<optimized out>) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qlist.h:933
#2 QListSpecialMethodsBase<QWaylandView*>::indexOf<QWaylandView*> (from=<optimized out>, t=<optimized out>, this=<optimized out>, this=<optimized out>, t=<optimized out>, from=<optimized out>)
at /usr/include/x86_64-linux-gnu/qt6/QtCore/qlist.h:966
#3 QListSpecialMethodsBase<QWaylandView*>::contains<QWaylandView*> (t=<optimized out>, this=<optimized out>, this=<optimized out>, t=<optimized out>) at /usr/include/x86_64-linux-gnu/qt6/QtCore/qlist.h:48
#4 QWaylandSurfacePrivate::refView (this=0x18, view=view@entry=0x55879c897370) at ./src/compositor/compositor_api/qwaylandsurface.cpp:1014
#5 0x00007f906aef1403 in QWaylandViewPrivate::setSurface (this=0x55879c897390, newSurface=<optimized out>) at ./src/compositor/compositor_api/qwaylandview.cpp:121
#5 0x00007f906aef1403 in QWaylandViewPrivate::setSurface (this=0x55879c897390, newSurface=<optimized out>) at ./src/compositor/compositor_api/qwaylandview.cpp:121
de/x86_64-linux-gnu/qt6/QtCore/qlist.h:48
#6 0x00007f906aef1498 in QWaylandView::setSurface (this=0x55879c897370, newSurface=<optimized out>) at ./src/compositor/compositor_api/qwaylandview.cpp:141
#7 0x00007f906af47b06 in QWaylandQuickItem::setSurface (this=0x55879c897010, surface=0x55879c55e060) at ./src/compositor/compositor_api/qwaylandquickitem.cpp:560
#8 0x00007f908006733d in PluginManagerIntegration::PluginManagerIntegration (this=this@entry=0x55879c4745a0, item=item@entry=0x55879c897010) at ./panels/dock/pluginmanagerintegration.cpp:16
#9 0x00007f9080060d25 in PluginSurface::createIntegration (this=<optimized out>, item=0x55879c897010) at ./panels/dock/pluginmanagerextension.cpp:187
#10 0x00007f906af5074d in QWaylandQuickShellSurfaceItem::setShellSurface (this=0x55879c897010, shellSurface=0x55879c55cf10) at ./src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp:117
```
Influence:
1. 测试动态表面创建和销毁时的插件管理功能
2. 验证当表面被删除时仍被引用时不会发生崩溃
3. 测试多个插件实例时的停靠面板行为
4. 验证合成器操作期间的内存安全性
5. 检查插件加载/卸载功能是否有回归问题1 parent 1d96fad commit 87b7184
1 file changed
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | | - | |
| 9 | + | |
11 | 10 | | |
12 | 11 | | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
198 | | - | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
272 | | - | |
| 273 | + | |
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
| |||
0 commit comments