fix: make DConfig fully functional on Windows - #578
Conversation
- Replace Unix-specific getuid()/getpwuid() with Windows equivalents using GetUserNameW() and MD5-based user ID generation - Fix path handling for cross-platform: support empty localPrefix, use ';' as path separator on Windows, fallback to QStandardPaths for DSG data directories on non-Linux - Move dconfigfile.cpp compilation and D_DSG_APP_DATA_FALLBACK definition out of LINUX-only block in CMake - Define D_DISABLE_DBUS_CONFIG instead of D_DISABLE_DCONFIG on non-Linux platforms fix: 使 DConfig 在 Windows 上完整可用 - 使用 GetUserNameW() 和基于 MD5 的用户 ID 生成替代 Unix 特有的 getuid()/getpwuid(),实现 Windows 平台用户标识 - 修复跨平台路径处理:支持空 localPrefix、Windows 上使用分号作为 路径分隔符、非 Linux 平台通过 QStandardPaths 获取 DSG 数据目录 - CMake 中将 dconfigfile.cpp 编译和 D_DSG_APP_DATA_FALLBACK 定义 移出仅限 Linux 的条件块 - 非 Linux 平台定义 D_DISABLE_DBUS_CONFIG 而非 D_DISABLE_DCONFIG
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kt286 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 |
|
Hi @kt286. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideMake DConfig fully functional and buildable on Windows by replacing Linux-specific user identification and path handling logic with cross-platform/Windows equivalents, and adjusting CMake flags so DConfig is enabled and DBus config is disabled on non-Linux platforms. Sequence diagram for FileBackend user cache creation on Linux vs WindowssequenceDiagram
participant FileBackend
participant DConfigFile
participant DConfigCache
FileBackend->>DConfigFile: DConfigFile(owner->appId, owner->name, owner->subpath)
alt Q_OS_LINUX
FileBackend->>DConfigFile: createUserCache(getuid)
else Q_OS_WIN
FileBackend->>FileBackend: getWindowsUserId
FileBackend->>DConfigFile: createUserCache(getWindowsUserId)
end
DConfigFile-->>FileBackend: DConfigCache pointer
FileBackend->>DConfigCache: load(localPrefix)
FileBackend->>DConfigFile: load(localPrefix)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
| // lower priority is higher. | ||
| for (auto item: DStandardPaths::paths(DStandardPaths::DSG::DataDir)) { | ||
| paths.prepend(QDir::cleanPath(QString("%1/%2/configs").arg(localPrefix, item))); | ||
| if (localPrefix.isEmpty()) { |
There was a problem hiding this comment.
正常场景下都会为空,这个是给玲珑环境准备的吧
There was a problem hiding this comment.
举个例子
Linux环境中 item 是 /usr/share,localPrefix 是玲珑那个/perxxxx 的,如果不是玲珑环境就是 /usr/share/config 玲珑环境就是 /perxxxx/usr/share/config 这样都没问题
但是 Windows 下没有玲珑环境 localPrefix 默认为空 item 是一个 C:/xxx 这样的格式,拼接起来就变成了 /C:/xxx/config,这样的目录是解析不出来的
fix: 使 DConfig 在 Windows 上完整可用
Summary by Sourcery
Make DConfig fully operational on Windows by adding Windows-specific user identification, path handling, and build configuration support while preserving Linux behavior.
New Features:
Bug Fixes:
Enhancements:
Build: