Fix: [GPU] GPU info not show.#547
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom Nov 7, 2025
Merged
Conversation
-- Some special platform, GPU info not show. -- Pre cache the GPU info. Log: fix issue Bug: https://pms.uniontech.com/bug-view-340131.html
Reviewer's GuideCentralize platform configuration loading in main.cpp, add GPU info pre-caching for custom device types, and remove redundant config logic from MainWindow. Sequence diagram for GPU info pre-caching on custom device typessequenceDiagram
participant Main as main.cpp
participant DConfig as DConfig
participant Common as Common
participant CommonTools as CommonTools
Main->>DConfig: create("org.deepin.devicemanager")
DConfig-->>Main: DConfig instance
Main->>DConfig: isValid()
DConfig-->>Main: true/false
Main->>DConfig: keyList().contains("specialComType")
DConfig-->>Main: true/false
Main->>DConfig: value("specialComType")
DConfig-->>Main: int value
Main->>Common: set specialComType
Main->>DConfig: keyList().contains("TomlFilesName")
DConfig-->>Main: true/false
Main->>DConfig: value("TomlFilesName")
DConfig-->>Main: tomlFilesName
Main->>Common: tomlFilesNameSet(tomlFilesName)
alt specialComType == kCustomType
Main->>CommonTools: preGenerateGpuInfo()
end
Class diagram for updated Common and CommonTools usageclassDiagram
class Common {
+int specialComType
+static void tomlFilesNameSet(QString)
+const int kCustomType
+static QString boardVendorType()
}
class CommonTools {
+static void preGenerateGpuInfo()
}
CommonTools <.. Main : uses
Common <.. Main : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review我来对这个diff进行审查:
DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager");
// ... 使用dconfig
delete dconfig;或者使用QScopedPointer: QScopedPointer<DConfig> dconfig(DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager"));
bool isValid = dconfig && dconfig->isValid();
if (isValid && dconfig->keyList().contains("specialComType")) {
// ...
}
if (isValid && dconfig->keyList().contains("TomlFilesName")) {
// ...
}
if (dconfig && dconfig->isValid() && dconfig->keyList().contains("specialComType")) {
QVariant value = dconfig->value("specialComType");
if (value.canConvert<int>()) {
Common::specialComType = value.toInt();
} else {
qCWarning(appLog) << "Invalid specialComType value in config";
}
}
namespace ConfigKeys {
const QString SPECIAL_COM_TYPE = "specialComType";
const QString TOML_FILES_NAME = "TomlFilesName";
}
qCInfo(appLog) << "Loading config from org.deepin.devicemanager, specialComType:" << Common::specialComType;
这些改进将使代码更加健壮、安全和可维护。 |
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `deepin-devicemanager/src/main.cpp:112` </location>
<code_context>
}
});
titlebar()->addWidget(mp_ButtonBox);
-#ifdef DTKCORE_CLASS_DConfigFile
- //需要查询是否支持特殊机型静音恢复,例如hw机型
- DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager");
</code_context>
<issue_to_address>
**issue (complexity):** Consider consolidating configuration validation and key reading into a single block or helper function for improved clarity and reduced repetition.
```cpp
#ifdef DTKCORE_CLASS_DConfigFile
// collapse validation & read all keys in one block, then handle GPU logic
auto dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager");
if (dconfig && dconfig->isValid()) {
// read both keys without repeating isValid()
if (dconfig->keyList().contains("specialComType")) {
Common::specialComType = dconfig->value("specialComType").toInt();
}
if (dconfig->keyList().contains("TomlFilesName")) {
Common::tomlFilesNameSet(dconfig->value("TomlFilesName").toString());
}
qCInfo(appLog) << "Common::specialComType value is:" << Common::specialComType;
// isolate GPU pre-generation
if (Common::specialComType == Common::kCustomType) {
CommonTools::preGenerateGpuInfo();
}
}
#endif
```
Or extract into a helper for clarity:
```cpp
#ifdef DTKCORE_CLASS_DConfigFile
static void loadCustomConfig() {
auto cfg = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager");
if (!cfg || !cfg->isValid()) return;
Common::specialComType = cfg->value("specialComType", Common::specialComType).toInt();
Common::tomlFilesNameSet(cfg->value("TomlFilesName", QString()).toString());
qCInfo(appLog) << "Common::specialComType value is:" << Common::specialComType;
if (Common::specialComType == Common::kCustomType)
CommonTools::preGenerateGpuInfo();
}
loadCustomConfig();
#endif
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
max-lvs
approved these changes
Nov 7, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017, max-lvs 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 |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
beb3ba1
into
linuxdeepin:develop/eagle
16 of 18 checks passed
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.
-- Some special platform, GPU info not show.
-- Pre cache the GPU info.
Log: fix issue
Bug: https://pms.uniontech.com/bug-view-340131.html
Summary by Sourcery
Load special platform configuration and pre-generate GPU information at application startup to fix missing GPU info, and remove duplicate config loading from the MainWindow.
Bug Fixes:
Enhancements: