-
Notifications
You must be signed in to change notification settings - Fork 57
fix(tests): fix build for Qt 6.9 #343
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
Conversation
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#343
|
LGTM |
| QPlatformServices *MinimalIntegration::services() const | ||
| { | ||
| if (!m_services) | ||
| #if QT_VERSION >= 0x060900 |
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.
类似 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
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.
目前的写法更为通用,如果用 QT_VERSION_CHECK 可能会导致 moc 不可用
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.
这个是 Qt 4 (以及很早期的 Qt 5)时代的问题,目前是 Qt 5/6 了,不需要担心这个。建议修改为使用 QT_VERSION_CHECK
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.
我们使用的qt版本应该是大于5.11,这moc会有问题么,另外,dtk里绝大多数用的都是QT_VERSION_CHECK,qt源码里也使用的是QT_VERSION,好像没出现过moc问题,是不是qt后面已经修了,
QT_VERSION_CHECK可读性也更好些,
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.
已修改
Qt 6.9 renamed <private/qdesktopunixservices_p.h> to <private/qgenericunixservices_p.h>, as well as some of the classes along the same format (QGenericUnixServices => QDesktopUnixServices). Add a condition test with QT_VERSION to fix build with Qt >= 6.9. Signed-off-by: Mingcong Bai <jeffbai@aosc.io>
055ca92 to
6c8fe1a
Compare
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#343
deepin pr auto review这段代码是一个Qt平台插件测试相关的实现,主要处理不同Qt版本间的兼容性问题。我来分析一下这段代码: 语法逻辑代码逻辑基本正确,使用了条件编译来处理不同Qt版本间的差异。通过 代码质量
代码性能
代码安全
改进建议// 建议添加注释说明版本差异的原因
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
// Qt 6.9.0起,QGenericUnixServices已被QDesktopUnixServices替代
#include <private/qdesktopunixservices_p.h>
#else
#include <private/qgenericunixservices_p.h>
#endif
// 可以考虑将版本检查提取为辅助函数
inline bool isQt69OrLater()
{
return QT_VERSION >= QT_VERSION_CHECK(6, 9, 0);
}
QPlatformServices *MinimalIntegration::services() const
{
if (!m_services) {
if (isQt69OrLater()) {
m_services.reset(new QDesktopUnixServices);
} else {
m_services.reset(new QGenericUnixServices);
}
}
return m_services.get();
}总结这段代码整体质量良好,主要处理了Qt版本兼容性问题。建议的改进主要集中在代码可读性和可维护性方面,而不是功能或安全性问题。如果项目有更高的要求,可以考虑添加错误处理和更详细的日志记录。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, MingcongBai 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 |
Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: linuxdeepin/dtkgui#343
Qt 6.9 renamed <private/qdesktopunixservices_p.h> to <private/qgenericunixservices_p.h>, as well as some of the classes along the same format (QGenericUnixServices => QDesktopUnixServices).
Add a condition test with QT_VERSION to fix build with Qt >= 6.9.