-
Notifications
You must be signed in to change notification settings - Fork 40
Fix: [GPU] GPU info not show. #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: [GPU] GPU info not show. #547
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
[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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
beb3ba1
into
linuxdeepin:develop/eagle
-- 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: