Skip to content

fix: clear *pprocess when file copy fails in DocumentFactory::getDocument - #413

Open
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:fix/getdocument-pprocess
Open

add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:fix/getdocument-pprocess

Conversation

@add-uos

@add-uos add-uos commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

问题

reader/document/Model.cpp:160 的 QFile::copy(targetDoc) 失败分支返回 nullptr 并置 error = ConvertFailed,但 *pprocess 未置空。函数其余全部错误分支(:188/:194/:201/:229/:235/:263/:269/:278/:284)均在返回前置 *pprocess = nullptr,成功路径亦有赋值——该分支是唯一破坏出口参数约定的。实测混合跑中 *process 残留调用方原值(非空),依赖 *process == nullptr 判断的调用方会误判(当前 PageRenderThread.cpp:859 恰好预置了 nullptr 故未实际崩溃,属低危契约缺陷)。

修复

失败分支 return nullptr 前补 *pprocess = nullptr;,与其余错误分支语义对齐。

背景

该问题由 AI 辅助单测(PMS 缺陷热点回归,BUG332133 用例运行时发现)。

Summary by Sourcery

Bug Fixes:

  • Clear the process output parameter when document file copying fails, keeping failure behavior consistent with all other error paths.

…ment

Every other error branch of getDocument() sets *pprocess = nullptr
before returning, but the QFile::copy() failure path left the output
parameter untouched, so callers relying on *process == nullptr could
read a stale pointer. Align the branch with the rest.

Log:
Influence: document opening

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes DocumentFactory::getDocument so a failed document file copy clears *pprocess before returning, preventing callers from observing stale process state.

File-Level Changes

Change Details Files
Aligns the file-copy failure path with the function’s output-parameter cleanup contract.
  • Sets the process output pointer to nullptr before returning on copy failure.
  • Preserves the existing ConvertFailed error and nullptr document return behavior.
reader/document/Model.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants