Skip to content

fix: app will automatically fill in from the first page of folder#573

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-288821
Jun 9, 2025
Merged

fix: app will automatically fill in from the first page of folder#573
BLumia merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-288821

Conversation

@wjyrich
Copy link
Copy Markdown
Contributor

@wjyrich wjyrich commented Jun 9, 2025

as title.

PMS-BUG-288821

Summary by Sourcery

Bug Fixes:

  • Replace fallback to the last page for negative page requests with scanning for and filling the first page that has room, or appending a new page if all are full.

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

关键摘要:

  • insertItemToPage 函数中,toPage 参数的初始值处理逻辑存在错误,toPage 被重置为 -1 但在后续逻辑中并没有使用这个值。
  • Q_ASSERT(toPage < m_pages.count()); 断言在 toPage 被重置为 -1 后仍然执行,可能会导致程序崩溃。
  • insertItem 函数的调用中,pos 参数被硬编码为 m_pages[toPage].count(),这可能会导致插入位置不正确。

是否建议立即修改:

  • 修正 toPage 的初始值处理逻辑,确保其正确性。
  • 移除或修改 Q_ASSERT 断言,以避免在 toPage 为 -1 时程序崩溃。
  • 重新考虑 insertItem 函数的调用逻辑,确保 pos 参数的设置符合预期。

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jun 9, 2025

Reviewer's Guide

Enhanced insertItemToPage to support automatic slot allocation from the first page when toPage is negative, create new pages if no free slots exist, and cleaned up the outdated fallback logic.

Sequence Diagram for ItemsPage::insertItemToPage Enhanced Logic

sequenceDiagram
    participant C as Caller
    participant IP as ItemsPage

    C->>IP: insertItemToPage(id, originalToPage)

    alt originalToPage < 0 (Automatic slot allocation)
        IP-->>IP: Search m_pages for page with empty slot
        alt Empty slot found
            IP-->>IP: Update toPage = found_page_index
            %% Execution continues
        else No empty slot found in existing pages
            IP-->>IP: appendPage({id})
            IP-->>C: return
        end
    end

    %% Execution continues if not returned from the block above

    alt m_pages.count() == 0 (No pages exist currently)
        IP-->>IP: appendPage({id})
        IP-->>C: return
    end

    %% Execution continues if not returned from previous blocks
    %% Assumes toPage is now a valid index and m_pages is not empty
    IP-->>IP: insertItem(id, toPage, position_in_page)
Loading

Updated Class Diagram for ItemsPage

classDiagram
  class ItemsPage {
    +insertItemToPage(id: QString, toPage: int): void
    #insertItem(id: QString, page: int, pos: int): void
    #appendPage(ids: QStringList): void
    #m_pages: Collection
    #m_maxItemCountPerPage: int
  }
Loading

File-Level Changes

Change Details Files
Automatic slot filling and new page creation in insertItemToPage
  • Loop through existing pages to find the first one under capacity when toPage<0
  • Append a new page with the item if no slot is found
  • Add guard to append initial page if m_pages is empty
  • Remove the previous fallback that set toPage to the last page via qMax
src/models/itemspage.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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

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

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, wjyrich

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

@BLumia BLumia merged commit 4520c31 into linuxdeepin:master Jun 9, 2025
7 of 10 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