fix: Add dynamic path resolution for htmltopdf#188
Merged
lzwind merged 2 commits intolinuxdeepin:masterfrom Sep 3, 2025
Merged
fix: Add dynamic path resolution for htmltopdf#188lzwind merged 2 commits intolinuxdeepin:masterfrom
lzwind merged 2 commits intolinuxdeepin:masterfrom
Conversation
Added a new function getHtmlToPdfPath() to dynamically resolve the path for htmltopdf. Updated the htmltopdfCommand in getDocument to use this function instead of a hardcoded path, improving code flexibility and maintainability. bug: https://pms.uniontech.com/bug-view-332133.html
- update version to 6.5.36 log: update version to 6.5.36
|
TAG Bot TAG: 6.5.36 |
deepin pr auto review根据提供的git diff,我将对代码进行审查,并提出改进意见: 1. 代码逻辑审查
2. 代码质量改进建议
3. 代码性能改进建议
4. 代码安全改进建议
改进后的代码建议示例:QString getHtmlToPdfPath() {
// 预定义的搜索路径
const QStringList searchPaths = {
QString(INSTALL_PREFIX) + "/lib/deepin-reader/htmltopdf",
QLibraryInfo::path(QLibraryInfo::LibrariesPath) + "/deepin-reader/htmltopdf"
};
for (const QString& path : searchPaths) {
QFileInfo fileInfo(path);
if (fileInfo.exists() && fileInfo.isExecutable()) {
qInfo() << "Using htmltopdf at:" << path;
return fileInfo.absoluteFilePath();
}
}
qWarning() << "htmltopdf not found in any of the search paths";
return QString();
}
// 在调用处添加错误处理
QString htmltopdfPath = getHtmlToPdfPath();
if (htmltopdfPath.isEmpty()) {
qCritical() << "Failed to find htmltopdf tool";
return nullptr;
}
// 使用参数列表方式执行命令
QProcess converter2;
converter2.setProgram(htmltopdfPath);
converter2.setArguments({tmpHtmlFilePath, realFilePath});
converter2.setWorkingDirectory(convertedFileDir + "/word");
if (!converter2.start()) {
qCritical() << "Failed to start htmltopdf process";
return nullptr;
}这些改进可以提高代码的健壮性、安全性和可维护性。 |
lzwind
approved these changes
Sep 3, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
This was referenced Sep 3, 2025
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.
fix: Add dynamic path resolution for htmltopdf