Skip to content

fix(reader): close FindWidget on tab switch to prevent cross-document… - #370

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
GongHeng2017:202609041642-master-fix
Sep 8, 2026
Merged

fix(reader): close FindWidget on tab switch to prevent cross-document…#370
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
GongHeng2017:202609041642-master-fix

Conversation

@GongHeng2017

@GongHeng2017 GongHeng2017 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

… search

When switching between document tabs, the FindWidget (whose parent is the MainWindow, not the SheetBrowser) remained visible with its m_docSheet pointer still bound to the previous document. Searching from this stale widget executed the search on the wrong document.

Add SheetBrowser::hideFindWidget() to hide and destroy the FindWidget, DocSheet::closeFindWidget() to stop the search and hide the widget, and call prevSheet->closeFindWidget() in CentralDocPage::onTabChanged() before switching to the new tab.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-376317.html

Summary by Sourcery

Prevent cross-document searches by closing the previous document’s FindWidget before switching tabs.

Bug Fixes:

  • Close and destroy the active document’s FindWidget when switching tabs to prevent searches from targeting the previous document.

Enhancements:

  • Centralize search cleanup across DocSheet and SheetBrowser during document tab changes.

… search

When switching between document tabs, the FindWidget (whose parent is
the MainWindow, not the SheetBrowser) remained visible with its
m_docSheet pointer still bound to the previous document. Searching
from this stale widget executed the search on the wrong document.

Add SheetBrowser::hideFindWidget() to hide and destroy the FindWidget,
DocSheet::closeFindWidget() to stop the search and hide the widget, and
call prevSheet->closeFindWidget() in CentralDocPage::onTabChanged()
before switching to the new tab.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-376317.html
@sourcery-ai

sourcery-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

The tab-switch flow now stops searches and removes the previous document’s FindWidget before activating another document, preventing a MainWindow-owned widget from retaining a stale document binding and searching across tabs.

Sequence diagram for closing FindWidget during document tab switching

sequenceDiagram
    participant CentralDocPage
    participant PrevDocSheet
    participant SheetBrowser
    participant FindWidget

    CentralDocPage->>PrevDocSheet: closeFindWidget()
    PrevDocSheet->>PrevDocSheet: stopSearch()
    PrevDocSheet->>SheetBrowser: hideFindWidget()
    SheetBrowser->>FindWidget: hide()
    SheetBrowser->>FindWidget: deleteLater()
    SheetBrowser-->>SheetBrowser: m_findWidget = nullptr
    CentralDocPage->>CentralDocPage: saveCurrentViewState()
    CentralDocPage-->>CentralDocPage: activate new tab
Loading

File-Level Changes

Change Details Files
Explicitly close and destroy the active document’s find widget before switching tabs.
  • Added a SheetBrowser helper that hides, schedules destruction of, and clears the find-widget pointer.
  • Added a DocSheet-level operation that stops searching and delegates widget cleanup to its browser.
  • Invoked cleanup for the previous sheet during tab changes before saving state and activating the new tab.
reader/browser/SheetBrowser.cpp
reader/browser/SheetBrowser.h
reader/uiframe/DocSheet.cpp
reader/uiframe/DocSheet.h
reader/uiframe/CentralDocPage.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

@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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-bot

deepin-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.5.64
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #371

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, 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

@GongHeng2017

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 78deba7 into linuxdeepin:master Sep 8, 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