fix(build): make DConfig optional for 102X-107X compatibility - #215
Conversation
Guard DConfig usage with HAVE_DCONFIG so builds succeed on older dtkcore versions that lack the DConfig header. 用#ifdef HAVE_DCONFIG保护DConfig调用,无DtkCore时回退到硬编码, 确保102X~107X全版本可编译。 Log: DConfig改为可选依赖,兼容低版本dtkcore Bug: https://pms.uniontech.com/bug-view-372777.html Influence: 解耦应用在102X~107X全版本可正常编译,低版本回退硬编码UFS版本列表。
There was a problem hiding this comment.
Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMake DConfig an optional dependency by conditionally defining HAVE_DCONFIG when DtkCore is available and guarding all DConfig-related includes and runtime usage with that macro, falling back to a hard-coded UFS spec version list when DConfig is not present so the project builds on 102X–107X dtkcore versions. Sequence diagram for ufsSpecVersions runtime behavior with optional DConfigsequenceDiagram
participant DeviceStorage
participant DConfig
DeviceStorage->>DeviceStorage: ufsSpecVersions()
DeviceStorage->>DeviceStorage: create fallback list
alt [HAVE_DCONFIG defined]
DeviceStorage->>DConfig: Dtk::Core::DConfig::create("com.deepin.diskmanager", "com.deepin.diskmanager.storage")
DConfig-->>DeviceStorage: cfg
alt [cfg && cfg->isValid()]
DeviceStorage->>DConfig: value("ufsSpecVersions")
DConfig-->>DeviceStorage: versions
alt [!versions.isEmpty()]
DeviceStorage-->>DeviceStorage: return versions
else [versions.isEmpty()]
DeviceStorage-->>DeviceStorage: return fallback
end
else [cfg invalid]
DeviceStorage-->>DeviceStorage: return fallback
end
else [HAVE_DCONFIG not defined]
DeviceStorage-->>DeviceStorage: return fallback
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够优秀,无需额外修改,此处展示当前最佳实践以供参考
static QStringList ufsSpecVersions()
{
const QStringList fallback{"300", "310", "400", "410"};
#ifdef HAVE_DCONFIG
QScopedPointer<Dtk::Core::DConfig> cfg(
Dtk::Core::DConfig::create("com.deepin.diskmanager", "com.deepin.diskmanager.storage"));
if (cfg && cfg->isValid()) {
QStringList versions = cfg->value("ufs_spec_versions").toStringList();
if (!versions.isEmpty())
return versions;
}
#endif
return fallback;
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: max-lvs, tianming-1996 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 |
|
/merge |
Guard DConfig usage with HAVE_DCONFIG so builds succeed on older dtkcore versions that lack the DConfig header.
用#ifdef HAVE_DCONFIG保护DConfig调用,无DtkCore时回退到硬编码,
确保102X~107X全版本可编译。
Log: DConfig改为可选依赖,兼容低版本dtkcore
Bug: https://pms.uniontech.com/bug-view-372777.html
Influence: 解耦应用在102X~107X全版本可正常编译,低版本回退硬编码UFS版本列表。
Summary by Sourcery
Make DConfig usage optional so the service and tests build with or without DtkCore across 102X–107X versions.
Enhancements:
Build: