fix(editor): harden StartManager teardown and singleton lifetime - #534
Conversation
Null static instance pointers in Settings and StartManager destructors so instance() never returns a dangling pointer after deleteLater in tests; give context to timer singleShots to skip firing on destroyed receivers; guard the tab tear-off animation with QPointer since the source EditWrapper may be closed during the 200ms animation (UAF); fall back to window size when the drag pixmap is null. Settings 与 StartManager 析构时置空静态指针,避免测试 deleteLater 后 instance() 返回悬空指针;延时 singleShot 补 context 对象,接收者 已销毁则不触发;标签撕出动画期间源 EditWrapper 可能被关闭,以 QPointer 防悬空(UAF 根源);拖拽 pixmap 为空时回退窗口尺寸。 Log: 修复标签撕出动画 UAF 与单例悬空问题 PMS: TASK-393979 Influence: 消除全量测试套件随机段错误与关标签时的偶发崩溃。
cacd114 to
da5074a
Compare
Reviewer's GuideHardens singleton lifetime management and deferred operations in StartManager and Settings to avoid dangling pointers and UAFs, and makes the tab tear‑off animation and drag pixmap logic robust against destroyed objects and null pixmaps. Sequence diagram for context-bound QTimer singleShot callssequenceDiagram
participant StartManager
participant Window
participant QTimer
StartManager->>Window: createWindow(true)
Window->>Window: showCenterWindow(true)
StartManager->>QTimer: singleShot(50, Window, lambda)
rect rgb(230,230,230)
note over Window,QTimer: During delay
Window--xWindow: destroyed
end
QTimer-->>Window: [lambda not invoked, context destroyed]
StartManager->>QTimer: singleShot(1000, StartManager, lambda)
rect rgb(230,230,230)
note over StartManager,QTimer: During delay
StartManager--xStartManager: deleteLater()
end
QTimer-->>StartManager: [lambda not invoked, context destroyed]
Sequence diagram for tab tear-off animation guarded by QPointersequenceDiagram
participant StartManager
participant QParallelAnimationGroup as AnimationGroup
participant EditWrapper as Buffer
participant QPointer as BufferGuard
participant Window as PWindow
StartManager->>BufferGuard: QPointer<EditWrapper> bufferGuard(Buffer)
StartManager->>AnimationGroup: new QParallelAnimationGroup
StartManager->>AnimationGroup: connect(finished, lambda)
rect rgb(230,230,230)
note over Buffer,AnimationGroup: During ~200ms animation
Buffer--xBuffer: destroyed
BufferGuard->>BufferGuard: isNull() == true
end
AnimationGroup-->>StartManager: finished()
StartManager->>BufferGuard: isNull()
alt bufferGuard.isNull()
StartManager-->>StartManager: drop tear-off
else bufferGuard not null
StartManager->>PWindow: show()
StartManager->>PWindow: showCenterWindow(false)
StartManager->>PWindow: addTabWithWrapper(Buffer, filePath, qstrTruePath, tabName)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In createWindowFromWrapper, consider parenting QParallelAnimationGroup (and possibly the QPropertyAnimations) to an appropriate QObject (e.g., pWindow or this) instead of relying solely on deleteLater in the finished handler, to avoid leaks if the animation is interrupted or never finishes.
- The added qDebug logging in the StartManager and Settings destructors might be noisy in normal application shutdown; consider using a categorized logging macro or limiting these messages to debug/test builds if they are primarily for tracking singleton teardown issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In createWindowFromWrapper, consider parenting QParallelAnimationGroup (and possibly the QPropertyAnimations) to an appropriate QObject (e.g., pWindow or this) instead of relying solely on deleteLater in the finished handler, to avoid leaks if the animation is interrupted or never finishes.
- The added qDebug logging in the StartManager and Settings destructors might be noisy in normal application shutdown; consider using a categorized logging macro or limiting these messages to debug/test builds if they are primarily for tracking singleton teardown issues.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Null static instance pointers in Settings and StartManager destructors so instance() never returns a dangling pointer after deleteLater in tests; give context to timer singleShots to skip firing on destroyed receivers; guard the tab tear-off animation with QPointer since the source EditWrapper may be closed during the 200ms animation (UAF); fall back to window size when the drag pixmap is null. Settings 与 StartManager 析构时置空静态指针,避免测试 deleteLater 后 instance() 返回悬空指针;延时 singleShot 补 context 对象,接收者 已销毁则不触发;标签撕出动画期间源 EditWrapper 可能被关闭,以 QPointer 防悬空(UAF 根源);拖拽 pixmap 为空时回退窗口尺寸。 Log: 修复标签撕出动画 UAF 与单例悬空问题 PMS: TASK-393979 Influence: 消除全量测试套件随机段错误与关标签时的偶发崩溃。
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已具备良好的安全性和健壮性,无需进一步修改。
// 仅作为示例展示保持现状即可。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx 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 |
|
/merge |
Null static instance pointers in Settings and StartManager destructors so instance() never returns a dangling pointer after deleteLater in tests; give context to timer singleShots to skip firing on destroyed receivers; guard the tab tear-off animation with QPointer since the source EditWrapper may be closed during the 200ms animation (UAF); fall back to window size when the drag pixmap is null.
Settings 与 StartManager 析构时置空静态指针,避免测试 deleteLater 后 instance() 返回悬空指针;延时 singleShot 补 context 对象,接收者 已销毁则不触发;标签撕出动画期间源 EditWrapper 可能被关闭,以
QPointer 防悬空(UAF 根源);拖拽 pixmap 为空时回退窗口尺寸。
Log: 修复标签撕出动画 UAF 与单例悬空问题
PMS: TASK-393979
Influence: 消除全量测试套件随机段错误与关标签时的偶发崩溃。
Summary by Sourcery
Harden editor teardown and tab tear-off handling to eliminate use-after-free crashes and invalid singleton access.
Bug Fixes: