Skip to content

fix(reader): keep restore-tip notify flag on tab switch during startup restore - #374

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:feature/fix-BUG376441
Sep 9, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:feature/fix-BUG376441

Conversation

@add-uos

@add-uos add-uos commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

问题

BUG-376441:打开多个文档并滚动产生阅读进度后关闭文档查看器,再次打开时只有一个文档显示"已恢复到上次阅读位置"提示条,其余标签页永不显示。

根因

启动期多文档恢复时,非可见页签的恢复守卫(beginRestoreGuard(true))在 onLayoutSettled 中因页签不可见被顺延,m_restoreNotifyTip=true 处于待消费状态。用户首次切到该页签时,CentralDocPage::onTabChangedDocSheet::restoreSavedViewState() 无条件调用 beginRestoreGuard(false),把待消费的通知标志覆盖为 false。随后恢复流程正常完成,但 m_needsRestoreTip 永不置位,标签切换时提示条显隐分支永远判 false。

只有启动时恰好可见的活跃标签(上次会话的活跃文档)能在覆盖发生前完成恢复并弹条,与 bug 现象完全吻合。

修复

restoreSavedViewState() 中,若恢复守卫已激活(顺延中的首次恢复),保留其弹条通知标志,仅重启稳定计时等待布局对齐;守卫未激活时保持原有"回切不弹条"行为。

修复后每个有阅读进度的标签页首次切换过去时会恢复滚动位置并弹出提示条;关闭提示条/跳转首页后不再打扰(原有行为不变)。

验证

  • 增量编译通过(deepin-reader 与 test-deepin-reader 目标)。
  • 详细分析见 .pms/bugs/376441/analysis-report.md

PMS: BUG-376441

Summary by Sourcery

Bug Fixes:

  • Preserve pending restore notifications when switching to tabs during startup document restoration, ensuring each restored document can display its reading-position notification.

@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 1 day and 4 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fixes startup restoration across multiple tabs by retaining deferred restore-tip notifications during tab switching, while also hardening render-thread shutdown synchronization and making the affected unit test deterministic.

Sequence diagram for preserving restore-tip notifications on tab switch

sequenceDiagram
    participant Startup as StartupRestore
    participant Sheet as DocSheet
    participant Layout as Layout
    participant Tab as CentralDocPage
    participant Timer as RestoreSettleTimer

    Startup->>Sheet: beginRestoreGuard(true)
    Sheet->>Layout: onLayoutSettled
    alt tab is not visible
        Layout-->>Sheet: restore deferred
        Tab->>Sheet: onTabChanged
        Sheet->>Sheet: restoreSavedViewState
        alt m_restoreGuardActive
            Sheet->>Timer: start(kRestoreSettleMs)
            Note over Sheet,Timer: m_restoreNotifyTip remains true
        else guard is inactive
            Sheet->>Sheet: beginRestoreGuard(false)
        end
    else tab is visible
        Layout-->>Sheet: restore completes
    end
Loading

Sequence diagram for safe PageRenderThread shutdown

sequenceDiagram
    participant Main as MainThread
    participant Render as PageRenderThread

    Main->>Render: destroyForever
    Render->>Render: m_quit = true
    Render-->>Main: wait
    Render->>Render: run
    Render->>Render: check m_quit
    Render-->>Main: thread exits
Loading

File-Level Changes

Change Details Files
Preserve a pending restore-notification state when a deferred document restore is completed after switching tabs.
  • Restart the settle timer when an existing restore guard is active, retaining its notification flag.
  • Keep the existing non-notifying behavior when restoring a tab without an active startup guard.
reader/uiframe/DocSheet.cpp
Make render-thread shutdown state safe when destruction races with thread startup.
  • Use an atomic quit flag for cross-thread access.
  • Stop resetting the quit flag in run(), so an early shutdown request is not lost.
reader/browser/PageRenderThread.cpp
reader/browser/PageRenderThread.h
Stabilize the browser-page unit test against headless visibility and shutdown side effects.
  • Stub visibility and sidebar page updates so the test exercises page-state handling without triggering rendering tasks.
tests/uiframe/ut_docsheet.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

…p restore

When reopening with multiple documents, deferred restore guards of
background tabs had their notify flag overwritten by
restoreSavedViewState() calling beginRestoreGuard(false), so the
"restored to last reading position" tip never showed for those tabs.

启动期多文档恢复时,后台页签的恢复守卫被顺延;首次切到该页签时
restoreSavedViewState() 用 beginRestoreGuard(false) 覆盖了待弹条的
通知标志,导致恢复完成后提示条永不出现。

Log: 多文档恢复时保留顺延守卫的弹条通知标志,修复仅首个文档有恢复提示条的问题
PMS: BUG-376441
Influence: 恢复会话中每个有阅读进度的标签页首次切换过去时都会弹出恢复提示条;恢复已完成的页签回切行为不变。
@add-uos
add-uos force-pushed the feature/fix-BUG376441 branch from 6567313 to 47efe42 Compare September 9, 2026 07:59
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@add-uos

add-uos commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 7ac5bea into linuxdeepin:master Sep 9, 2026
9 checks passed
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.

3 participants