Repository navigation
fix: correct default scale factor initialization - #50
Conversation
When the scale-factor setting from dconfig is invalid (<= 0), the code incorrectly used the invalid value to populate the "ALL" key in the ScaleFactors map. This would propagate an invalid scale factor (likely 0 or negative) to the system. The fix ensures that when no valid scale factor is configured, the recommendedScaleFactor parameter is used as the default value for all screens, providing a sensible fallback. Log: Fixed an issue where an invalid display scale factor setting could cause incorrect scaling. Influence: 1. Test display scaling when dconfig scale-factor is set to 0 or a negative value. 2. Verify that the recommended scale factor is applied correctly in such cases. 3. Ensure overall display scaling behavior remains consistent for valid settings. fix: 修正默认缩放因子初始化错误 当从 dconfig 读取的 scale-factor 设置无效(<= 0)时,代码错误地使用了 该无效值来填充 ScaleFactors 映射中的 "ALL" 键。这会导致将无效的缩放因子 (可能为 0 或负数)传播到系统。此修复确保当没有配置有效的缩放因子时,使 用 recommendedScaleFactor 参数作为所有屏幕的默认值,提供了一个合理的回退 方案。 Log: 修复了无效的显示缩放因子设置可能导致缩放不正确的问题。 Influence: 1. 测试当 dconfig 的 scale-factor 设置为 0 或负值时的显示缩放。 2. 验证在此类情况下,推荐的缩放因子被正确应用。 3. 确保对于有效的设置,整体显示缩放行为保持一致。 PMS: BUG-345701
deepin pr auto review我来对这个代码修改进行审查:
改进建议:
if (value <= 0 && recommendedScaleFactor > 0) {
ScaleFactors map;
map.insert("ALL", recommendedScaleFactor);
setScreenScaleFactors(map, false);
}
const QString ALL_SCREENS = "ALL";
// ...
map.insert(ALL_SCREENS, recommendedScaleFactor);
qDebug() << "Setting scale factor for all screens to:" << recommendedScaleFactor;总体来说,这个修改是必要的,它修复了一个可能导致系统使用无效缩放值的bug。修改后的代码更加合理和安全。 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes default display scale factor initialization so that when an invalid dconfig scale-factor (<= 0) is read, the system falls back to the recommendedScaleFactor for all screens instead of propagating the invalid value. Sequence diagram for fallback to recommended scale factor on invalid dconfig valuesequenceDiagram
participant XSettingsManager
participant DConfig
participant DisplaySystem
XSettingsManager->>DConfig: read_scale_factor
DConfig-->>XSettingsManager: value
XSettingsManager->>XSettingsManager: adjustScaleFactor recommendedScaleFactor
alt value <= 0
XSettingsManager->>XSettingsManager: set ALL scale factor = recommendedScaleFactor
XSettingsManager->>DisplaySystem: setScreenScaleFactors map false
else value > 0
XSettingsManager->>XSettingsManager: use configured scale factor
XSettingsManager->>DisplaySystem: apply configured scale factors
end
Flow diagram for scale factor initialization logicflowchart TD
A[Read scale factor from dconfig] --> B{value <= 0}
B -->|Yes| C[Create ScaleFactors map]
C --> D[Insert ALL with recommendedScaleFactor]
D --> E[Call setScreenScaleFactors map false]
B -->|No| F[Use existing valid scale factor handling]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, robertkill 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
When the scale-factor setting from dconfig is invalid (<= 0), the code incorrectly used the invalid value to populate the "ALL" key in the ScaleFactors map. This would propagate an invalid scale factor (likely 0 or negative) to the system. The fix ensures that when no valid scale factor is configured, the recommendedScaleFactor parameter is used as the default value for all screens, providing a sensible fallback.
Log: Fixed an issue where an invalid display scale factor setting could cause incorrect scaling.
Influence:
fix: 修正默认缩放因子初始化错误
当从 dconfig 读取的 scale-factor 设置无效(<= 0)时,代码错误地使用了
该无效值来填充 ScaleFactors 映射中的 "ALL" 键。这会导致将无效的缩放因子
(可能为 0 或负数)传播到系统。此修复确保当没有配置有效的缩放因子时,使
用 recommendedScaleFactor 参数作为所有屏幕的默认值,提供了一个合理的回退
方案。
Log: 修复了无效的显示缩放因子设置可能导致缩放不正确的问题。
Influence:
PMS: BUG-345701
Summary by Sourcery
Bug Fixes: