fix: prevent crash on toplevel destruction#1647
Conversation
There was a problem hiding this comment.
Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
gdb) bt |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Added proper destructor to ForeignToplevelHandle class to clean up the Wayland object when the instance is destroyed. Previously, the destructor was missing, causing the underlying treeland_foreign_toplevel_handle_v1 object to remain alive after the ForeignToplevelHandle wrapper was destroyed, leading to use-after-free crashes in the task manager. The fix ensures that when a ForeignToplevelHandle is destroyed, its associated Wayland protocol object is properly destroyed via the `destroy()` method, preventing dangling pointers and toplevel crashes. Log: Fixed crash when closing windows in the dock task manager Influence: 1. Open and close multiple applications rapidly to trigger toplevel destroy events 2. Test with applications that create and destroy windows frequently 3. Verify dock task manager remains stable during window management operations 4. Test with different types of windows (normal, dialog, transient) fix: 修复顶层窗口销毁时的崩溃问题 为 ForeignToplevelHandle 类添加了正确的析构函数,在实例销毁时清理 Wayland 对象。之前缺少析构函数,导致 ForeignToplevelHandle 包装类销毁 后,底层的 treeland_foreign_toplevel_handle_v1 对象仍然存在,导致任务管 理器出现释放后使用崩溃。 该修复确保了 ForeignToplevelHandle 被销毁时,其关联的 Wayland 协议对象通 过 `destroy()` 方法被正确销毁,防止悬空指针和顶层窗口崩溃。 Log: 修复关闭dock任务管理器中窗口时的崩溃问题 Influence: 1. 快速打开和关闭多个应用程序以触发顶层窗口销毁事件 2. 测试频繁创建和销毁窗口的应用程序 3. 验证窗口管理操作期间dock任务管理器的稳定性 4. 测试不同类型的窗口(普通窗口、对话框、临时窗口)
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已为最佳实践,无需额外修改,以下为完整确认示例
// treelandwindow.h
class ForeignToplevelHandle : public QWaylandClientExtensionTemplate<ForeignToplevelHandle> {
public:
explicit ForeignToplevelHandle(struct ::treeland_foreign_toplevel_handle_v1 *object);
~ForeignToplevelHandle();
// ...
};
// treelandwindow.cpp
ForeignToplevelHandle::ForeignToplevelHandle(struct ::treeland_foreign_toplevel_handle_v1 *object)
: QtWayland::treeland_foreign_toplevel_handle_v1(object)
, m_pid(0)
, m_isReady(false)
, m_identifier(0)
{
init(object);
}
ForeignToplevelHandle::~ForeignToplevelHandle()
{
if (object()) {
destroy();
}
} |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Added proper destructor to ForeignToplevelHandle class to
clean up the Wayland object when the instance is destroyed.
Previously, the destructor was missing, causing the underlying
treeland_foreign_toplevel_handle_v1 object to remain alive after the
ForeignToplevelHandle wrapper was destroyed, leading to use-after-free
crashes in the task manager.
The fix ensures that when a ForeignToplevelHandle is destroyed, its
associated Wayland protocol object is properly destroyed via the
destroy()method, preventing dangling pointers and toplevel crashes.Log: Fixed crash when closing windows in the dock task manager
Influence:
destroy events
operations
fix: 修复顶层窗口销毁时的崩溃问题
为 ForeignToplevelHandle 类添加了正确的析构函数,在实例销毁时清理
Wayland 对象。之前缺少析构函数,导致 ForeignToplevelHandle 包装类销毁
后,底层的 treeland_foreign_toplevel_handle_v1 对象仍然存在,导致任务管
理器出现释放后使用崩溃。
该修复确保了 ForeignToplevelHandle 被销毁时,其关联的 Wayland 协议对象通
过
destroy()方法被正确销毁,防止悬空指针和顶层窗口崩溃。Log: 修复关闭dock任务管理器中窗口时的崩溃问题
Influence: