fix: update QProcess command syntax for package management#603
fix: update QProcess command syntax for package management#603dengzhongyuan365-dev wants to merge 1 commit intolinuxdeepin:release/eaglefrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors QProcess invocations for package management operations to use the structured overload with a program name and QStringList of arguments instead of building shell command strings, improving safety, consistency, and readability across DriverManager, PageInfo, and Utils. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Refactor the way QProcess commands are constructed for package management functions in PageInfo, DriverManager, and Utils. This change improves readability and consistency by using QStringList for command arguments instead of string concatenation. https://pms.uniontech.com/task-view-386519.html
810d002 to
0bf1447
Compare
deepin pr auto review这段代码的修改主要是将 1. 代码改进点分析语法逻辑:✅ 改进正确
代码质量:✅ 改进良好
代码性能:
代码安全:✅ 显著提升
2. 进一步改进建议尽管修改已经提高了安全性,但还有一些地方可以进一步优化: a. 错误处理改进当前代码没有检查进程的退出状态或错误输出,建议添加错误处理: bool DriverManager::printerHasInstalled(const QString &packageName)
{
QProcess p;
p.start("sudo", QStringList() << "dpkg" << "-s" << packageName);
if (!p.waitForFinished(-1)) {
qWarning() << "dpkg command failed to execute:" << p.errorString();
return false;
}
if (p.exitCode() != 0) {
qWarning() << "dpkg command failed with exit code:" << p.exitCode();
return false;
}
QByteArray r = p.readAllStandardOutput();
return r.contains("Status: install ok installed");
}b. 避免使用
|
Refactor the way QProcess commands are constructed for package management functions in PageInfo, DriverManager, and Utils. This change improves readability and consistency by using QStringList for command arguments instead of string concatenation.
Summary by Sourcery
Use QProcess with separate program and argument list for package management commands to improve robustness and consistency across device manager components.
Enhancements: