Repository navigation
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm 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 |
This comment was marked as off-topic.
This comment was marked as off-topic.
cb1d44c to
072da37
Compare
This comment was marked as resolved.
This comment was marked as resolved.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: 无 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: 建议将 appSingleton 的 description 修改为更完整的描述,例如:"When set to true, Application Manager will treat the application as singleton: if an instance is already running, the launch splash will be suppressed. The value must be written under the subpath /. Intended for third-party applications that cannot modify their desktop files to add the X-Deepin-Singleton field." 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: 无 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: 无 💡 改进建议代码示例// 建议修改 DConfig 描述,使其更完整地反映单例语义 // 文件: misc/dsg/configs/dde-application-manager/org.deepin.dde.application-manager.json "appSingleton": {
"value": false,
"serial": 0,
"flags": [],
"name": "Declare application as singleton",
"name[zh_CN]": "声明应用为单例",
"description": "When set to true, Application Manager will treat the application as singleton: if an instance is already running, the launch splash will be suppressed. The value must be written under the subpath /<desktop-id> (the application desktop file ID). Intended for third-party applications that cannot modify their desktop files to add the X-Deepin-Singleton field.",
"permissions": "readwrite",
"visibility": "public"
}本报告由 AI 代码审查工具自动生成 |
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/dbus/applicationservice.cpp" line_range="500-501" />
<code_context>
- findEntryValue(fromStaticRaw(DesktopFileEntryKey), fromStaticRaw(DesktopEntryXDeepinSingleton), EntryValueType::Boolean)
- .toBool();
+ bool dconfigSingleton = false;
+ if (sharedDConfig && sharedDConfig->isValid()) {
+ dconfigSingleton = sharedDConfig->value(fromStaticRaw(AppSingleton)).toBool();
+ }
+
</code_context>
<issue_to_address>
**Singleton splash suppression is lost**
When DConfig is unavailable while a third-party app relies only on `appSingleton`, `sharedDConfig` is invalid, so `dconfigSingleton` remains false and the launch proceeds to show a splash for an app whose only singleton declaration is in DConfig.
Log a warning when the DConfig is invalid so operators can detect that the singleton declaration is not being applied.
</issue_to_address>
This comment was marked as outdated.
This comment was marked as outdated.
072da37 to
888153e
Compare
…op file Add DConfig 'appSingleton' configuration item for third-party applications to declare singleton behavior, and use existing desktop file 'X-Deepin-Singleton' field for self-developed applications. Both sources are OR-combined: if either is true and an instance is already running, Application Manager suppresses the launch splash for the duplicate launch. This extends singleton-aware splash suppression to third-party apps via DConfig. The singleton declaration (X-Deepin-Singleton / appSingleton) is metadata only; single-instance deduplication remains the application's own responsibility (DTK single-instance framework). Application Manager does not intercept or block duplicate launches — it only suppresses the splash screen to avoid a flash for apps that will immediately exit after activating the existing instance. The singleton check in Launch() uses a lazy IIFE: on first launch (the common hot path) m_Instances is empty so singletonWithInstance is always false and no DConfig query or findEntryValue call is made. Only when an instance already exists does the check proceed — first consulting the desktop file X-Deepin-Singleton (short-circuiting DConfig if true), then falling back to a DConfig appSingleton query. appendExtraEnvironments retains its original signature and creates its own DConfig internally. Changes: - misc/dsg/configs/dde-application-manager/org.deepin.dde.application-manager.json: add 'appSingleton' config item (bool, default false, readwrite, public) with description noting the value must be written under subpath /<desktop-id> - src/constant.h: add AppSingleton constant - src/dbus/applicationservice.cpp: lazy singletonWithInstance evaluation via IIFE in Launch(); fix nullptr safety in appendExtraEnvironments (config && config->isValid())
888153e to
6489040
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A temporary DConfig failure is cached as false, preventing retries and causing splash-screen suppression to remain disabled for the service’s lifetime even after configuration recovers.
1 open issue
What changed in this PR
Adds per-application DConfig singleton declarations alongside the existing desktop-file declaration to suppress splash screens when an instance is already running, without blocking repeat launches.
Changes:
- Adds the public, writable
appSingletonsetting and its constant. - Combines desktop and DConfig declarations with lazy lookup and a per-service cache.
- Adds a null check when loading extra environment settings.
| File | Description |
|---|---|
src/dbus/applicationservice.h |
Adds optional storage for the cached singleton setting. |
src/dbus/applicationservice.cpp |
Implements lazy singleton lookup and guards environment-config access. |
src/constant.h |
Defines the AppSingleton configuration key. |
misc/dsg/configs/dde-application-manager/org.deepin.dde.application-manager.json |
Declares and documents the per-app singleton setting. |
Review effort: Balanced
| m_dconfigSingleton = config && config->isValid() | ||
| && config->value(fromStaticRaw(AppSingleton)).toBool(); |

Summary
新增 DConfig
appSingleton配置项供三方应用声明单例;自研应用通过 desktop 文件X-Deepin-Singleton字段声明;两种方式 OR 合并用于 splash 抑制(不拦截重复启动);惰性判定 + DConfig 查询结果缓存。Changes
misc/dsg/configs/dde-application-manager/org.deepin.dde.application-manager.json): 新增appSingleton配置项(bool, 默认 false, readwrite, public),per-app subpath/<appId>,与appExtraEnvironments一致src/constant.h): 新增AppSingleton = u"appSingleton"常量src/dbus/applicationservice.h): 新增std::optional<bool> m_dconfigSingleton用于缓存 DConfig 查询结果src/dbus/applicationservice.cpp—Launch()方法):singletonWithInstance:m_Instances为空(首启)→ 直接 false,零开销X-Deepin-Singleton为 true → 直接 true,跳过 DConfig 查询appSingleton(per-app subpath),结果缓存到m_dconfigSingleton,后续调用复用singletonWithInstance为 true 时跳过 prelaunch splash(不拦截启动,应用正常启动)Behavior
appSingletonX-Deepin-SingletonNotes
X-Deepin-Singleton是声明性元数据,去重是应用自己的责任std::optional<bool>缓存,同一 ApplicationService 实例生命周期内只查询一次m_dconfigSingleton保持未初始化,查询结果为 false,不影响 desktop 文件声明的单例判断Multica Issue: DDE-470