Skip to content

fix: narrow resizeEvent updateSize condition to 1px - #800

Draft
18202781743 wants to merge 1 commit into
masterfrom
agent/bot/abcc5992c5f6
Draft

18202781743 wants to merge 1 commit into
masterfrom
agent/bot/abcc5992c5f6

Conversation

@18202781743

@18202781743 18202781743 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

修复内容

收窄 DDialog::resizeEvent 中 updateSize() 触发条件,从 width != oldWidth 改为 qAbs(width - oldWidth) <= 1,仅处理小数缩放比例下的 1 像素舍入差异。

根因

commit 36b4030a 在 DDialog::resizeEvent 中添加了对任意宽度变化都触发 updateSize() 的逻辑,在正常 show()->updateSize()->resize() 流程中导致递归重算,布局回缩到 sizeHint 宽度 (286px) 而窗口保持默认宽度 (380px)。

影响范围

  • 保留 BUG-370643 的小数缩放修复
  • 消除反复 show/hide/show 时布局塌缩问题

验证建议

  1. 测试 DDialog show/hide/show 循环,验证按钮行撑满窗口宽度
  2. 测试小数缩放比例 (1.25x、1.5x、1.75x) 下对话框显示
  3. 验证首次显示和反复 show/hide 后布局正常

关联 Issue

DDE-542

PMS: BUG-381331

1. Root cause: commit 36b4030 added updateSize() call in
   DDialog::resizeEvent triggered on any width change when
   WA_Resized is false, but this also fires during normal
   show()->updateSize()->resize() cycle causing recursive
   recalculation that shrinks layout to sizeHint width (286px)
   while window stays at default width (380px)
2. Fix: narrow the condition from width != oldWidth to
   qAbs(width - oldWidth) <= 1, matching the original intent
   of handling only fractional scaling 1px rounding differences
3. Impact: preserves BUG-370643 fractional scaling fix while
   preventing layout collapse on repeated show/hide/show cycles

Log: Fix dialog layout collapse on second show after hide

Influence:
1. Test DDialog show/hide/show cycle, verify buttons fill width
2. Test dialog under fractional scale (1.25x, 1.5x, 1.75x)
3. Verify first show and repeated show/hide maintain correct layout

fix: 收窄 resizeEvent 中 updateSize 触发条件为 1 像素

1. 根因:commit 36b4030 在 DDialog::resizeEvent 中添加了
   WA_Resized 为 false 且宽度变化时调用 updateSize() 的逻辑,
   但该条件对任意宽度变化都触发,在正常 show()->updateSize()
   ->resize() 流程中导致递归重算,布局回缩到 sizeHint 宽度
   (286px) 而窗口保持默认宽度 (380px)
2. 方案:将条件从 width != oldWidth 收窄为
   qAbs(width - oldWidth) <= 1,仅处理小数缩放比例下的
   1 像素舍入差异,符合原始设计意图
3. 影响:保留 BUG-370643 的小数缩放修复,同时消除反复
   show/hide/show 时布局塌缩的问题

Log: 修复对话框第二次显示后按钮行布局塌缩的问题

Influence:
1. 测试 DDialog show/hide/show 循环,验证按钮行撑满窗口宽度
2. 测试小数缩放比例 (1.25x、1.5x、1.75x) 下对话框显示
3. 验证首次显示和反复 show/hide 后布局正常

PMS: BUG-381331
@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

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

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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

@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Narrows DDialog::resizeEvent’s update-size condition to width changes of at most one pixel, retaining fractional scaling support while avoiding recursive recalculation that can collapse the layout during repeated show/hide cycles.

Sequence diagram for DDialog resize handling

sequenceDiagram
    participant DDialog
    participant DAbstractDialog
    DDialog->>DDialog: resizeEvent(QResizeEvent *event)
    alt width difference <= 1px and not WA_Resized
        DDialog->>DDialog: updateSize()
    else width difference > 1px or already resized
        DDialog->>DAbstractDialog: resizeEvent(event)
    end
Loading

File-Level Changes

Change Details Files
Restrict resize-triggered size recalculation to one-pixel width differences, preserving fractional-DPI rounding correction while preventing recursive layout shrinkage.
  • Replace the any-width-change check with an absolute width-difference threshold of at most 1 pixel.
  • Keep the existing WA_Resized guard and normal dialog resize handling intact.
src/widgets/ddialog.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

@18202781743
18202781743 marked this pull request as draft November 3, 2026 03:24

This branch has not been deployed

No deployments
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.

2 participants