fix: use setter for short idle state initialization - #175
Merged
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuidePower-saving configuration initialization now uses the short-idle state setter, ensuring consistent state management and triggering any associated side effects when configurations are loaded or reloaded. Sequence diagram for short-idle configuration initializationsequenceDiagram
participant DConfig
participant SystemPowerManager
participant ShortIdleState
DConfig->>SystemPowerManager: initPowerSavingDConfig()
SystemPowerManager->>SystemPowerManager: setShortIdleState(value.toBool())
SystemPowerManager->>ShortIdleState: Apply state management and side effects
ShortIdleState-->>SystemPowerManager: State updated
Flow diagram for short-idle configuration reloadflowchart TD
A[Load power-saving configuration] --> B{short idle state key}
B -->|present| C["setShortIdleState(value.toBool())"]
C --> D[State and side effects remain consistent]
B -->|absent| E[Continue loading other power-saving options]
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 found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/plugin-qt/power/system/powermanager.cpp" line_range="554" />
<code_context>
m_shortIdleEnabled = value.toBool();
else if (key == QLatin1String(kShortIdleState))
- m_shortIdleState = value.toBool();
+ setShortIdleState(value.toBool());
else if (key == QLatin1String(kIdleStatePath))
m_idleStatePath = value.toString();
</code_context>
<issue_to_address>
**issue (bug_risk):** `initPowerSavingDConfig()` loads `kShortIdleState` before `kShortIdleEnable`, but `setShortIdleState()` immediately returns while `m_shortIdleEnabled` is false. Consequently, a configuration with short idle enabled and state enabled leaves `m_shortIdleState` false after initialization; the later direct assignment of `m_shortIdleEnabled` does not retry the state.
**Triggers:** When the configured short-idle state is true and the short-idle feature is enabled.
**Suggested fix:** Load `kShortIdleEnable` before `kShortIdleState`, or defer applying the state until the enable flag has been initialized; apply the same ordering/deferral for runtime configuration updates.
</issue_to_address>
mhduiy
approved these changes
Sep 20, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, wjyrich 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 |
1. Replace direct assignment of m_shortIdleState with setShortIdleState() call in initPowerSavingDConfig() 2. Ensure proper state management and any side effects handled by the setter are triggered during configuration initialization 3. Prevent potential inconsistency where the short idle state is set without invoking the proper setter logic Log: Fixed short idle state not being properly initialized when loading power saving configuration Influence: 1. Test power saving configuration initialization with short idle enabled and disabled 2. Verify short idle state behaves correctly after configuration changes 3. Test toggling short idle state through DConfig and verify the setter side effects are triggered 4. Verify no regression in other power saving configuration options (idle state, screen state) 5. Test system behavior when short idle is enabled/disabled during runtime configuration reload fix: 使用 setter 初始化短空闲状态 1. 在 initPowerSavingDConfig() 中将 m_shortIdleState 的直接赋值替换为 setShortIdleState() 调用 2. 确保配置初始化期间能够正确触发 setter 中的状态管理和副作用处理 3. 防止短空闲状态在未调用正确 setter 逻辑的情况下被设置而导致潜在的不 一致 Log: 修复加载省电配置时短空闲状态未正确初始化的问题 Influence: 1. 测试短空闲启用和禁用时的省电配置初始化 2. 验证配置变更后短空闲状态的行为是否正确 3. 测试通过 DConfig 切换短空闲状态,验证 setter 的副作用是否被触发 4. 验证其他省电配置项(空闲状态、屏幕状态)无回归问题 5. 测试运行时配置重新加载时短空闲启用/禁用的系统行为 PMS: BUG-376709
wjyrich
force-pushed
the
fix-bug-376709
branch
from
September 20, 2026 06:24
59b6cc6 to
6094705
Compare
Contributor
Author
|
/forcemerge |
|
This pr force merged! (status: blocked) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log: Fixed short idle state not being properly initialized when loading power saving configuration
Influence:
fix: 使用 setter 初始化短空闲状态
Log: 修复加载省电配置时短空闲状态未正确初始化的问题
Influence:
PMS: BUG-376709
Summary by Sourcery
Bug Fixes: