fix(dconfig): cache configuration objects for the compositor lifetime - #1252
fix(dconfig): cache configuration objects for the compositor lifetime#1252zzxyb wants to merge 1 commit into
Conversation
Add SystemDConfigManager to centrally own and cache global, user, seat, output, and application DConfig objects. Delay Treeland startup until the global and initial user configurations are initialized, abort on global initialization failure, and fall back to generated defaults when user configuration initialization fails. Log: centralize DConfig initialization and lifetime management PMS: TASK-393777 Influence: DConfig startup, user switching, and hot-plugged output/input configuration
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zzxyb 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 |
Reviewer's GuideIntroduce a central SystemDConfigManager to own and cache Treeland DConfig objects, and defer Treeland startup until global and initial user configurations are initialized, replacing scattered per-component DConfig creation and tightening initialization/error-handling paths. Sequence diagram for Treeland startup with SystemDConfigManager-managed DConfig initializationsequenceDiagram
participant main
participant app as QGuiApplication
participant configMgr as SystemDConfigManager
participant treeland as Treeland
participant tlPriv as TreelandPrivate
main->>app: construct
main->>configMgr: SystemDConfigManager(&app)
configMgr->>configMgr: globalConfig = TreelandConfig::create
alt globalConfig.initializeFailed
configMgr-->>app: InitializeFailed
app-->>main: exit(1)
else globalConfig.initializeSucceed
configMgr-->>app: InitializeSucceed
app->>main: startTreeland()
main->>treeland: std::make_unique<Treeland>()
treeland->>tlPriv: init(onInitialized)
tlPriv->>configMgr: initializeUserConfigs(initialUserName)
alt userConfigsAlreadySucceeded
tlPriv->>tlPriv: initializeTreeland()
tlPriv-->>treeland: onInitialized()
treeland->>treeland: initialize()
else userConfigsPending
tlPriv->>configMgr: initialUserConfig()
tlPriv->>configMgr: seatUserConfig(initialUserName)
configMgr-->>tlPriv: TreelandUserConfig
configMgr-->>tlPriv: SeatUserDConfig
tlPriv->>TreelandUserConfig: connect(configInitializeSucceed/Failed)
tlPriv->>SeatUserDConfig: connect(configInitializeSucceed/Failed)
TreelandUserConfig-->>tlPriv: configInitializeSucceed or Failed
SeatUserDConfig-->>tlPriv: configInitializeSucceed or Failed
tlPriv->>tlPriv: initializeWhenReady()
tlPriv->>tlPriv: initializeTreeland()
tlPriv-->>treeland: onInitialized()
treeland->>treeland: initialize()
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull request overview
中文:本 PR 引入 SystemDConfigManager 作为全局 DConfig 中央管理与缓存点,并将 Helper/Input/Output/WindowConfigStore 等处的分散配置对象创建迁移到该中心,以便在合成器生命周期内复用配置对象并统一初始化流程;同时在启动阶段等待全局与初始用户配置初始化结果后再进入 Treeland 初始化逻辑。
English: This PR introduces SystemDConfigManager as a centralized owner/cache for global, user, seat, output, and app DConfig wrapper objects, refactors multiple call sites to fetch configs from the manager, and gates Treeland startup on global + initial user config initialization outcomes.
Changes:
- Add
SystemDConfigManagersingleton to own and cache DConfig wrapper instances across compositor lifetime. - Delay Treeland startup until global + initial user/seat configs reach a terminal initialization state (abort on global failure; warn/fallback on user/seat failure).
- Refactor
Helper,InputManager,Output, andWindowConfigStoreto use cached config instances instead of constructing their own.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/seat/helper.h |
Switch config ownership from unique_ptr to cached raw pointers. |
src/seat/helper.cpp |
Fetch global/user configs from SystemDConfigManager; adjust user-switch wiring. |
src/output/output.cpp |
Fetch per-output config from the shared config manager. |
src/main.cpp |
Create SystemDConfigManager early and gate Treeland startup on its init signals. |
src/input/inputmanager.cpp |
Reuse cached seat-user config; improve stale-pointer safety during async init. |
src/core/windowconfigstore.h |
Remove per-instance app-config cache storage. |
src/core/windowconfigstore.cpp |
Retrieve per-app configs from SystemDConfigManager. |
src/core/treeland.h |
Add initialize() to support delayed initialization. |
src/core/treeland.cpp |
Delay compositor initialization until user/seat config init completes (with fallback). |
src/core/systemdconfigmanager.h |
New centralized DConfig manager interface + caches. |
src/core/systemdconfigmanager.cpp |
New centralized DConfig manager implementation + global init forwarding. |
src/CMakeLists.txt |
Build integration for the new manager source files. |
Suppressed comments (1)
src/seat/helper.cpp:1915
- 中文:现在
TreelandUserConfig对象会被SystemDConfigManager缓存复用,同一个用户可能多次触发updateCurrentUser()(UserModel::setCurrentUserName不会去重)。这里对configInitializeSucceed的连接不是 single-shot/unique,可能累积多次连接,导致onConfigInitialized()被重复执行(重复 reload、重复同步等)。建议用Qt::SingleShotConnection。
English: With SystemDConfigManager caching, the same TreelandUserConfig instance can be reused, and updateCurrentUser() may be invoked repeatedly for the same user (since UserModel::setCurrentUserName doesn’t de-dup). This configInitializeSucceed connection is neither single-shot nor unique, so it can accumulate and call onConfigInitialized() multiple times. Use Qt::SingleShotConnection.
connect(m_config,
&TreelandUserConfig::configInitializeSucceed,
this,
onConfigInitialized);
}
| if (auto *configManager = SystemDConfigManager::instance()) { | ||
| m_config = configManager->initialUserConfig(); | ||
| m_globalConfig = configManager->globalConfig(); | ||
| } | ||
|
|
||
| Q_ASSERT(m_config); | ||
| Q_ASSERT(m_globalConfig); |
| QString outputName = WallpaperManager::getOutputId(output->output()->nativeHandle()); | ||
| m_config = OutputConfig::createByName("org.deepin.dde.treeland.output", | ||
| "org.deepin.dde.treeland", | ||
| "/" + outputName, this); | ||
| auto *configManager = SystemDConfigManager::instance(); | ||
| Q_ASSERT(configManager); | ||
| m_config = configManager ? configManager->outputConfig(outputName) : nullptr; |
| if (outputName.isEmpty()) { | ||
| return nullptr; | ||
| } |
| Q_SIGNALS: | ||
| void InitializeSucceed(); | ||
| void InitializeFailed(); |
| TreelandUserConfig *initialUserConfig() const; | ||
|
|
||
| Q_SIGNALS: | ||
| void InitializeSucceed(); |
| connect(m_globalConfig, | ||
| &TreelandConfig::configInitializeSucceed, | ||
| this, | ||
| [this](DTK_CORE_NAMESPACE::DConfig *) { Q_EMIT InitializeSucceed(); }, |
| SystemDConfigManager systemDConfigManager(&app); | ||
| std::unique_ptr<Treeland::Treeland> treeland; | ||
|
|
||
| auto startTreeland = [&treeland] { |
| } | ||
|
|
||
| quitCode = app.exec(); | ||
| } |
| QHash<QString, SeatUserDConfig *> m_seatUserConfigs; | ||
| QHash<QString, OutputConfig *> m_outputConfigs; | ||
| QHash<QString, AppConfig *> m_appConfigs; | ||
| TreelandUserConfig *m_initialUserConfig = nullptr; |
| // Creates and caches the initial user's configs. Returns true only when both | ||
| // configs have already finished successfully; callers should listen for | ||
| // their initialization signals when this returns false. | ||
| bool initializeUserConfigs(const QString &userName); |
There was a problem hiding this comment.
应该叫 setCurrentUser?
不过为啥要在这里做这样的封装,treeland.cpp 里直接使用 userConfig 获取,自己做当前config对象存储。
|
|
||
| #ifndef DISABLE_DDM | ||
| auto userModel = qmlEngine->singletonInstance<UserModel *>("Treeland", "UserModel"); | ||
| const QString initialUserName = userModel ? userModel->currentUserName() |
There was a problem hiding this comment.
userModel 里要加一个 pendingUserXXXX 的方法,当这个用户对应的dconfig未reday时,它还不是currentUser,对于想要切换到的user,应该先为pending状态,对应的dconfig reday后才变成currentUser,避免依赖 UserModel::currentUserNameChanged 的地方认为用户切换完成误用了dconfig。
There was a problem hiding this comment.
user对应的dconfig未完成初始化时,所有的也有代码逻辑能获取到的信息都应该是旧的,相当于没有进行user的切换。
|
TAG Bot New tag: 0.8.18 |
Add SystemDConfigManager to centrally own and cache global, user, seat, output, and application DConfig objects.
Delay Treeland startup until the global and initial user configurations are initialized, abort on global initialization failure, and fall back to generated defaults when user configuration initialization fails.
Log: centralize DConfig initialization and lifetime management
PMS: TASK-393777
Influence: DConfig startup, user switching, and hot-plugged output/input configuration
Summary by Sourcery
Introduce a central SystemDConfigManager to own and cache global, user, seat, output, and application configuration objects, and integrate it into Treeland startup and runtime.
New Features:
Enhancements: