Repository navigation
fix: 修复取消追加/移除文件操作时应用崩溃的问题 - #498
Merged
deepin-bot[bot] merged 1 commit intoOct 10, 2026
Merged
deepin-bot[bot] merged 1 commit into
deepin-bot[bot] merged 1 commit into
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes cancellation crashes by checking whether the archive job pointer was cleared synchronously by kill() and slotJobFinished(); redundant cleanup is skipped when completion already handled deletion, while the existing fallback cleanup remains for unsuccessful kills. Sequence diagram for safe archive operation cancellationsequenceDiagram
participant ArchiveManager
participant ArchiveJob
ArchiveManager->>ArchiveJob: kill()
alt kill triggers slotJobFinished synchronously
ArchiveJob-->>ArchiveManager: slotJobFinished()
ArchiveManager->>ArchiveManager: m_pArchiveJob = nullptr
ArchiveManager-->>ArchiveManager: skip deleteLater()
else kill fails
ArchiveJob-->>ArchiveManager: kill() returns false
ArchiveManager->>ArchiveJob: deleteLater()
ArchiveManager->>ArchiveManager: m_pArchiveJob = nullptr
end
ArchiveManager-->>ArchiveManager: return true
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 found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/source/archivemanager/archivemanager.cpp" line_range="457-460" />
<code_context>
if (m_pArchiveJob) {
qDebug() << "Canceling archive job";
m_pArchiveJob->kill();
- m_pArchiveJob->deleteLater();
- m_pArchiveJob = nullptr;
+ if (m_pArchiveJob) {
+ m_pArchiveJob->deleteLater();
+ m_pArchiveJob = nullptr;
+ }
return true;
</code_context>
<issue_to_address>
**Follow-up archive job is discarded**
When a direct `signalJobFinished` listener starts another archive operation before `kill()` returns, `slotJobFinished()` clears the old job and emits the signal; the listener sets `m_pArchiveJob` to the new job, then `cancelOperation()` schedules that job for deletion and clears its pointer, so the follow-up operation loses manager tracking and completion handling.
Keep the job being cancelled and only delete or clear `m_pArchiveJob` if it still points to that job.
</issue_to_address>
dengzhongyuan365-dev
force-pushed
the
agent/pms-bug-bot/7e5d64caefbd
branch
2 times, most recently
from
October 10, 2026 03:15
d34f301 to
f08b468
Compare
cancelOperation()中调用m_pArchiveJob->kill()后,kill()通过DirectConnection 同步触发slotJobFinished(),该槽函数将m_pArchiveJob置为nullptr并调用 deleteLater()。控制权返回cancelOperation()后,继续对已置空的m_pArchiveJob 调用deleteLater()导致空指针解引用崩溃。 修复方案:在kill()之前保存当前job指针到局部变量,kill()之后检查m_pArchiveJob 是否仍指向同一job。若slotJobFinished()已清理指针(kill成功),跳过冗余清理; 若kill失败(m_pArchiveJob未变),照常执行deleteLater()和置空。使用指针比较 而非简单null check,可防止slotJobFinished()的signalJobFinished监听者同步 启动新操作替换m_pArchiveJob时误删新job。 Log: 修复取消操作时空指针解引用崩溃 PMS: bug-378823
dengzhongyuan365-dev
force-pushed
the
agent/pms-bug-bot/7e5d64caefbd
branch
from
October 10, 2026 03:21
f08b468 to
bc001ef
Compare
lzwind
approved these changes
Oct 10, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
Member
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause Analysis
Crash on cancel during add/remove file operations in the archive manager. The root cause is a null pointer dereference in
cancelOperation(): after callingm_pArchiveJob->kill(), thekill()internally triggersslotJobFinished()viaDirectConnectionsynchronously, which setsm_pArchiveJob = nullptrand callsdeleteLater(). When control returns tocancelOperation(), the subsequentm_pArchiveJob->deleteLater()dereferences the now-null pointer, causing a crash.Key evidence:
archivemanager.cpp:456—m_pArchiveJob->kill()triggers synchronousslotJobFinished()archivemanager.cpp:505—slotJobFinished()setsm_pArchiveJob = nullptrviadeleteLater()archivemanager.cpp:457— back incancelOperation(),m_pArchiveJob->deleteLater()dereferences nullFix
Added a null check on
m_pArchiveJobafterkill(): ifslotJobFinished()has already cleaned up the pointer (kill succeeded), skip the redundant cleanup; otherwise (kill failed,doKill()returned false), performdeleteLater()and null assignment as before.Change Safety Assessment
Code Safety
ut_archivemanager.cpp) remain compatible — the stub forkill()prevents synchronousslotJobFinished(), so the null-check branch executesdeleteLater()as before.Business Impact Scope
The fix affects the "Cancel Operation" feature across all archive operation types (create, open, add, extract, delete, rename). Users clicking "Cancel" during any archive operation will no longer experience a crash. No other user-facing behavior changes.
Verification Suggestion
Regression test all cancel scenarios: cancel during add files (original bug scenario), cancel during remove files (original bug scenario), cancel during create/extract, and verify normal operation after cancel (state reset correctness).
根因分析
归档管理器在追加/移除文件过程中取消操作时崩溃。根因是
cancelOperation()中的空指针解引用:调用m_pArchiveJob->kill()后,kill() 通过 DirectConnection 同步触发slotJobFinished(),该槽函数将m_pArchiveJob置为 nullptr 并调用deleteLater()。控制权返回cancelOperation()后,继续对已置空的m_pArchiveJob调用deleteLater()导致空指针解引用崩溃。关键证据:
archivemanager.cpp:456—m_pArchiveJob->kill()同步触发slotJobFinished()archivemanager.cpp:505—slotJobFinished()置空m_pArchiveJob并调用deleteLater()archivemanager.cpp:457— 返回cancelOperation()后m_pArchiveJob->deleteLater()解引用空指针修复方案
在
kill()之后对m_pArchiveJob添加空指针检查:若slotJobFinished()已清理指针(kill 成功),跳过冗余清理;否则(kill 失败,doKill()返回 false)照常执行deleteLater()和置空。改动安全评估
代码安全评估
ut_archivemanager.cpp)均兼容——stub 阻止了同步slotJobFinished(),null check 分支照常执行deleteLater(),行为不变。业务影响范围
修复影响所有归档操作类型(创建、打开、追加、解压、删除、重命名)的"取消操作"功能。用户在任意归档操作过程中点击"取消"不再崩溃。无其他面向用户的行为变化。
验证建议
回归测试所有取消场景:追加文件时取消(bug 原场景)、移除文件时取消(bug 原场景)、创建/解压时取消,以及取消后再次执行操作验证状态正确重置。
Summary by Sourcery
Bug Fixes: