Skip to content

pick from master - #393

Merged
deepin-bot[bot] merged 3 commits into
linuxdeepin:release/snipefrom
add-uos:release/snipe
Sep 18, 2026
Merged

deepin-bot[bot] merged 3 commits into
linuxdeepin:release/snipefrom
add-uos:release/snipe

Conversation

@add-uos

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

Copy link
Copy Markdown
Contributor

pick from master

Summary by Sourcery

Harden asynchronous document rendering against object-lifetime races and unify dark-theme thumbnail rendering across sidebar views.

New Features:

  • Apply consistent dark-theme rendering to thumbnails, bookmarks, notes, and search results while preserving photo regions and handling scanned pages.
  • Cache thumbnail image-object bounds for use by sidebar night-mode rendering.

Bug Fixes:

  • Prevent use-after-free during asynchronous rendering by decoupling worker tasks from document and page lifetimes, clearing stale tasks, and rejecting callbacks for destroyed objects.
  • Avoid delayed pinch-gesture callbacks accessing destroyed browser instances.
  • Clean orphaned tab-group records along with bookmarks.

Enhancements:

  • Make rendering tasks use shared renderer ownership and value snapshots for safer worker-thread execution.
  • Move document-opening process handoff back to the main thread and route task validation through document UUIDs.

Tests:

  • Add coverage for renderer task cleanup, thumbnail image-bound propagation, safe document opening, and dark-theme rendering behavior across sidebar delegates.

Render task structs now carry a renderer shared reference and a uuid
snapshot; workers dereference only those and skip tasks whose sheet is
gone (existSheetByUuid). DocSheet owns SheetRenderer via QSharedPointer
and purges queued tasks (clearAllTasksForSheet/Page) before
destruction. BrowserPage validates page aliveness before writing render
results back, and the pinch-zoom timer callback is bound to its
receiver to avoid UAF.

渲染任务结构体改为携带渲染器共享引用与入队时快照的 uuid:worker 线
程仅解引用这两者,并经 existSheetByUuid 跳过已销毁文档的任务。
DocSheet 改用 QSharedPointer 持有 SheetRenderer,析构前排空排队任务
(clearAllTasksForSheet/Page);BrowserPage 回写渲染结果前校验页面
存活;捏合缩放定时器回调绑定 receiver,消除悬空指针。

Log: 渲染任务生命周期加固,消除文档销毁后 worker/回包路径悬空指针
PMS: BUG-377151
Influence: 文档关闭/缩放过程中渲染回调不再有悬空指针风险;正常渲染行为不变。
…han states

Cleanup could leave dangling references because bookmarks and tab
groups were removed independently while ownership records were still
being reconciled; the residue was re-persisted by later sync runs.

孤立状态下的书签与标签组独立清理时归属记录仍在协调,残留项会被
后续同步再次落盘。

Log: 修复孤立状态下书签与标签组清理不同步导致残留引用的问题
Influence: 数据库书签与标签组清理逻辑,孤立状态下不再残留悬挂引用。
Sidebar thumbnails followed eye-protection mode and stayed white in
dark theme. Now they follow the system theme only: white pages are
inverted via the shared NightFilter (CIELAB L*), image objects keep
original colors through a mask prefetched by the worker and cached
with the thumbnail, and scanned pages (>70% coverage) are fully
inverted. Bookmark/notes lists and the search-result page thumbnails
follow the same rules, and mask rects are scaled to the scaled pixmap
before filtering.

侧边栏缩略图原先跟随护眼模式,深色主题下仍是白底。现改为只跟随系统
深浅主题:白底经主干夜间滤镜(CIELAB L*)反转为黑底白字,照片区域按
worker 预取、随缩略图缓存的图片对象蒙版保持原色,扫描页(覆盖率超
70%)整页反色;书签/注释列表与搜索结果页的页面小图同规则,蒙版坐标
先映射到缩放后的像素图再进滤镜。

Log: 侧边栏缩略图/书签/注释/搜索结果深色主题反色并支持图片对象蒙版
PMS: BUG-377151
Influence: 深色主题下侧边栏(含触发搜索后的结果页)观感与主视图一致,浅色主题显示不变。

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

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR hardens asynchronous document rendering against sheet/page lifetime races by passing immutable task snapshots and shared renderer ownership, adds thumbnail image-region metadata for consistent NightFilter-based dark-mode rendering across sidebar views, cleans tab-group orphans, and updates comprehensive unit tests and stubs.

Sequence diagram for lifetime-safe asynchronous page rendering

sequenceDiagram
    participant BrowserPage
    participant PageRenderThread
    participant SheetRenderer
    participant MainThread

    BrowserPage->>PageRenderThread: appendTask(renderer, uuid, pageIndex)
    PageRenderThread->>SheetRenderer: getImage(pageIndex, ...)
    SheetRenderer-->>PageRenderThread: rendered image
    PageRenderThread-->>MainThread: sigDocPageNormalImageTaskFinished(task, pixmap)
    MainThread->>BrowserPage: existPage(task.page)
    alt page is alive
        MainThread->>BrowserPage: handleRenderFinished(pixmapId, pixmap)
    else page was destroyed
        MainThread-->>PageRenderThread: discard stale callback
    end
Loading

Sequence diagram for dark-mode thumbnail metadata flow

sequenceDiagram
    participant SideBarImageViewModel
    participant PageRenderThread
    participant SheetRenderer
    participant DocSheet
    participant ThumbnailDelegate
    participant NightFilter

    SideBarImageViewModel->>PageRenderThread: appendTask(renderer, uuid, index)
    PageRenderThread->>SheetRenderer: getImage(index, 174, 174)
    PageRenderThread->>SheetRenderer: getImageObjectRects(index, 174, 174)
    PageRenderThread-->>SideBarImageViewModel: handleRenderThumbnail(index, pixmap, imageRects)
    SideBarImageViewModel->>DocSheet: setThumbnail(index, pixmap, imageRects)
    ThumbnailDelegate->>DocSheet: data(IMAGE_NIGHT_MASK)
    ThumbnailDelegate->>NightFilter: applyPage(pixmap, imageRects)
    NightFilter-->>ThumbnailDelegate: dark-mode pixmap
Loading

Entity relationship diagram for document orphan cleanup

erDiagram
    DOCUMENT ||--o{ BOOKMARK : contains
    DOCUMENT ||--o{ TABGROUP : contains
    DOCUMENT {
        string filePath
    }
    BOOKMARK {
        string filePath
    }
    TABGROUP {
        string filePath
    }
Loading

File-Level Changes

Change Details Files
Reworked asynchronous rendering and document-opening tasks to avoid worker-thread access to destructible UI objects.
  • Capture shared renderer references and value snapshots (UUID, page index, file metadata, scale/size) when enqueueing tasks.
  • Use UUID validation and shared renderer ownership in worker execution instead of dereferencing DocSheet or BrowserPage.
  • Move QProcess ownership assignment back to the main-thread open callback.
  • Add sheet/page task cleanup, page-lifetime tracking, and callback guards against stale responses.
  • Update renderer ownership and APIs to use QSharedPointer and parentless SheetRenderer instances.
reader/browser/BrowserPage.cpp
reader/browser/BrowserPage.h
reader/browser/PageRenderThread.cpp
reader/browser/PageRenderThread.h
reader/browser/SheetBrowser.cpp
reader/sidebar/SideBarImageViewModel.cpp
reader/sidebar/SideBarImageViewModel.h
reader/uiframe/DocSheet.cpp
reader/uiframe/DocSheet.h
reader/uiframe/SheetRenderer.cpp
reader/uiframe/SheetRenderer.h
Added thumbnail image-object metadata propagation for intelligent dark-theme rendering.
  • Prefetch image-object bounding boxes during thumbnail rendering and carry them through the model into DocSheet thumbnail storage.
  • Expose the metadata through a new IMAGE_NIGHT_MASK model role.
  • Add cleanup behavior so replacing a thumbnail clears stale bounding boxes.
reader/browser/PageRenderThread.cpp
reader/browser/PageRenderThread.h
reader/sidebar/SideBarImageViewModel.cpp
reader/sidebar/SideBarImageViewModel.h
reader/uiframe/DocSheet.cpp
reader/uiframe/DocSheet.h
Unified sidebar and search-result thumbnail dark-mode presentation through the NightFilter pipeline.
  • Replace delegate-local HSL inversion with NightFilter-based rendering that preserves image regions and handles scanned-page full inversion.
  • Add scaled-coordinate handling, cached transformed pixmaps, and dark-theme border styling for notes.
  • Make thumbnail display follow system theme rather than eye-protection mode.
reader/sidebar/BookMarkDelegate.cpp
reader/sidebar/NotesDelegate.cpp
reader/sidebar/NotesDelegate.h
reader/sidebar/SearchResDelegate.cpp
reader/sidebar/SearchResDelegate.h
reader/sidebar/ThumbnailDelegate.cpp
reader/sidebar/ThumbnailDelegate.h
Extended orphan cleanup to remove tab-group records along with bookmarks.
  • Delete tabgroup rows associated with orphaned file paths within the existing cleanup transaction.
reader/app/Database.cpp
Expanded and adapted unit coverage for task lifetime safety, thumbnail metadata, and dark-theme rendering.
  • Update stubs and API call sites for shared renderer/open-task changes.
  • Add thumbnail image-rectangle propagation and worker prefetch tests.
  • Add light/dark theme, image-mask, scanned-page, and eye-protection behavior tests for sidebar delegates.
tests/browser/ut_browserpage.cpp
tests/browser/ut_pagerenderthread.cpp
tests/browser/ut_sheetbrowser.cpp
tests/sidebar/ut_bookmarkdelegate.cpp
tests/sidebar/ut_notesdelegate.cpp
tests/sidebar/ut_searchresdelegate.cpp
tests/sidebar/ut_sidebarimageviewmodel.cpp
tests/sidebar/ut_thumbnaildelegate.cpp
tests/uiframe/ut_docsheet.cpp
tests/uiframe/ut_sheetrenderer.cpp
tests/ut_mainwindow.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

@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 18, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit a9df07b into linuxdeepin:release/snipe Sep 18, 2026
8 of 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