fix: prevent icon size flickering when DPR changes with empty sourceSize#642
fix: prevent icon size flickering when DPR changes with empty sourceSize#64218202781743 wants to merge 1 commit into
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefines DQuickIconImage’s response to device pixel ratio changes so that icon URLs are recalculated only when the DPR actually updates, preventing icon size flicker under fractional scaling (especially on Wayland with empty sourceSize), and updates the file copyright years. Sequence diagram for updated DPR handling in DQuickIconImage::itemChangesequenceDiagram
participant QQuickItem as QQuickItem
participant DQuickIconImage as DQuickIconImage
participant DPrivate as DQuickIconImagePrivate
QQuickItem->>DQuickIconImage: itemChange(ItemSceneChange, value)
DQuickIconImage->>DQuickIconImage: qmlEngine(this)
alt qmlEngine is not null
DQuickIconImage->>DPrivate: updateDevicePixelRatio(1.0)
alt DPR actually changed (returns true)
DQuickIconImage->>DPrivate: maybeUpdateUrl()
else DPR unchanged (returns false)
DQuickIconImage-->>QQuickItem: no URL update
end
else qmlEngine is null
DQuickIconImage-->>QQuickItem: ignore change
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider adding a short comment explaining why
updateDevicePixelRatio(1.0)is called with a hardcoded 1.0 here, so future readers understand the rationale for this specific value in the context of Qt’s DPR handling. - If
updateDevicePixelRatiohas observable side effects (e.g., recalculating internal state), it might be worth checking whether this logic should be centralized or reused from existing code paths to avoid duplicating DPR update behavior in multiple places.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding a short comment explaining why `updateDevicePixelRatio(1.0)` is called with a hardcoded 1.0 here, so future readers understand the rationale for this specific value in the context of Qt’s DPR handling.
- If `updateDevicePixelRatio` has observable side effects (e.g., recalculating internal state), it might be worth checking whether this logic should be centralized or reused from existing code paths to avoid duplicating DPR update behavior in multiple places.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1. Fixed an issue where icon size flickering occurred under fractional scaling on Wayland, caused by Qt resetting devicePixelRatio without calling updateDevicePixelRatio when sourceSize is empty 2. Added condition to call maybeUpdateUrl only when device pixel ratio actually changes in itemChange, ensuring consistent icon rendering Log: Fixed icon flickering issue under Wayland fractional scaling when sourceSize is empty Influence: 1. Test icon rendering under Wayland with fractional scaling (e.g., 125%, 150%) 2. Verify no flickering when window moves between monitors with different DPIs 3. Check icon display when sourceSize is explicitly set 4. Test with empty sourceSize to ensure stable behavior 5. Verify on non-Wayland platforms to maintain existing functionality fix: 修复空sourceSize时DPR变化导致图标大小闪烁问题 1. 修复了Wayland下分数缩放时,当sourceSize为空,Qt重置devicePixelRatio但 未调用updateDevicePixelRatio导致的图标大小闪烁问题 2. 在itemChange中添加条件判断,仅在设备像素比实际发生变化时才调用 maybeUpdateUrl,确保图标渲染一致性 Log: 修复Wayland分数缩放下图标闪烁问题 Influence: 1. 在Wayland环境下测试分数缩放(如125%、150%)时的图标渲染 2. 验证窗口在不同DPI显示器间移动时无闪烁 3. 检查显式设置sourceSize时的图标显示 4. 测试空sourceSize情况以确保行为稳定 5. 在非Wayland平台上验证以保持现有功能正常 PMS: BUG-366597
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 void DQuickIconImage::itemChange(ItemChange change, const ItemChangeData &value)
{
Q_D(DQuickIconImage);
switch (change) {
case ItemDevicePixelRatioHasChanged: {
if (d->updateDevicePixelRatio(1.0)) {
d->maybeUpdateUrl();
}
}
break;
case ItemEnabledHasChanged: {
// ###!(Chen Bin): When the program exits, it will be called
// again, but the engine has been freed, causing subsequent
// operations to crash.
if (!engine())
return;
d->_q_reload();
}
break;
default:
break;
}
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
scaling on Wayland, caused by Qt resetting devicePixelRatio without
calling updateDevicePixelRatio when sourceSize is empty
actually changes in itemChange, ensuring consistent icon rendering
Log: Fixed icon flickering issue under Wayland fractional scaling when
sourceSize is empty
Influence:
125%, 150%)
different DPIs
fix: 修复空sourceSize时DPR变化导致图标大小闪烁问题
未调用updateDevicePixelRatio导致的图标大小闪烁问题
maybeUpdateUrl,确保图标渲染一致性
Log: 修复Wayland分数缩放下图标闪烁问题
Influence:
PMS: BUG-366597
Summary by Sourcery
Prevent icon flickering caused by unnecessary icon URL updates when the device pixel ratio changes, particularly under Wayland fractional scaling with empty sourceSize.
Bug Fixes:
Chores: