Skip to content

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

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
GongHeng2017:202609081440-re-eagle-fix
Sep 8, 2026
Merged

fix(reader): close FindWidget on tab switch to prevent cross-document…#372
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
GongHeng2017:202609081440-re-eagle-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 search widget before activating a new tab.

Bug Fixes:

  • Close and destroy the active document's FindWidget when switching tabs to prevent searches from being executed against the previously selected document.

Enhancements:

  • Centralize FindWidget shutdown by stopping its search before removing the widget during document transitions.

… 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

Fix cross-document search after tab switches by stopping the previous sheet’s search and hiding/deleting its FindWidget before activating the new document, with explicit cleanup APIs and updated copyright metadata.

Sequence diagram for closing search on document tab switch

sequenceDiagram
    participant CentralDocPage
    participant PreviousDocSheet
    participant PreviousSheetBrowser
    participant NewDocSheet

    CentralDocPage->>PreviousDocSheet: closeFindWidget()
    PreviousDocSheet->>PreviousDocSheet: stopSearch()
    PreviousDocSheet->>PreviousSheetBrowser: hideFindWidget()
    PreviousSheetBrowser->>PreviousSheetBrowser: hide()
    PreviousSheetBrowser->>PreviousSheetBrowser: deleteLater()
    CentralDocPage->>CentralDocPage: setCurrentWidget(NewDocSheet)
    CentralDocPage->>NewDocSheet: defaultFocus()
Loading

File-Level Changes

Change Details Files
Ensure document-tab switches terminate any search UI and state associated with the previous document.
  • Detect the currently displayed sheet before changing the stacked widget.
  • Close the previous sheet’s find widget only when switching to a different opened sheet.
  • Stop its active search before removing the widget.
reader/uiframe/CentralDocPage.cpp
reader/uiframe/DocSheet.cpp
reader/uiframe/DocSheet.h
Add lifecycle management for the FindWidget owned through the sheet browser.
  • Introduce a helper that hides and schedules deletion of the FindWidget.
  • Clear the widget pointer after scheduling deletion.
  • Expose the helper for DocSheet shutdown handling.
reader/browser/SheetBrowser.cpp
reader/browser/SheetBrowser.h
Update copyright metadata in all touched source and header files.
  • Replace legacy copyright lines with the 2019–2026 SPDX copyright declaration.
reader/browser/SheetBrowser.cpp
reader/browser/SheetBrowser.h
reader/uiframe/CentralDocPage.cpp
reader/uiframe/DocSheet.cpp
reader/uiframe/DocSheet.h

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-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, max-lvs

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 8bfd245 into linuxdeepin:release/eagle 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