diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-06-14 13:07:32 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-06-16 19:42:12 +0200 |
commit | 408fbd3f2d7a6b87521f5b3c27ecf6341dc06e13 (patch) | |
tree | dcff3d846ff9817f0390275e4e3d9d8045a772e2 /src/widgets/dialogs | |
parent | 684070bc342ac8e041c7156f0aa594b89b2265db (diff) |
QMessageBox: Remove include of qdebug.h
Move the implementation qRequireVersion() to prevent having
to include qdebug.h which pulls in many other headers.
Amends b5d874e36fd39fa6e57ff27db27ae0b029949749.
Fix missing include introduced by
3a553507a134bee1562d34ebbf786a053d36fc05.
Pick-to: 6.6
Task-number: QTBUG-114214
Task-number: QTBUG-97601
Change-Id: Iba68ffca95061666d9458ffa5700d07c7669da5b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 22 | ||||
-rw-r--r-- | src/widgets/dialogs/qmessagebox.h | 20 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 58e846b16b..dde15fbaf3 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -30,11 +30,17 @@ #include "private/qabstractbutton_p.h" #include <QtGui/qpa/qplatformtheme.h> +#include <QtCore/qanystringview.h> +#include <QtCore/qdebug.h> +#include <QtCore/qversionnumber.h> + #ifdef Q_OS_WIN # include <QtCore/qt_windows.h> #include <qpa/qplatformnativeinterface.h> #endif +#include <memory> + QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; @@ -2841,6 +2847,22 @@ void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHel clickedButton = button; } +Q_WIDGETS_EXPORT void _q_requireVersion(int argc, char *argv[], QAnyStringView req) +{ + const auto required = QVersionNumber::fromString(req).normalized(); + const auto current = QVersionNumber::fromString(qVersion()).normalized(); + if (current >= required) + return; + std::unique_ptr<QApplication> application; + if (!qApp) + application = std::make_unique<QApplication>(argc, argv); + const QString message = QApplication::tr("Application \"%1\" requires Qt %2, found Qt %3.") + .arg(qAppName(), required.toString(), current.toString()); + QMessageBox::critical(nullptr, QApplication::tr("Incompatible Qt Library Error"), + message, QMessageBox::Abort); + qFatal("%s", qPrintable(message)); +} + #if QT_DEPRECATED_SINCE(6,2) /*! \deprecated diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index 161719e180..2dee2e9204 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -5,17 +5,13 @@ #define QMESSAGEBOX_H #include <QtWidgets/qtwidgetsglobal.h> -#include <QtWidgets/qapplication.h> #include <QtWidgets/qdialog.h> -#include <QtCore/qanystringview.h> -#include <QtCore/qdebug.h> -#include <QtCore/qversionnumber.h> - QT_REQUIRE_CONFIG(messagebox); QT_BEGIN_NAMESPACE +class QAnyStringView; class QLabel; class QMessageBoxPrivate; class QAbstractButton; @@ -319,18 +315,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QMessageBox::StandardButtons) [[maybe_unused]] static inline void qRequireVersion(int argc, char *argv[], QAnyStringView req) { - const auto required = QVersionNumber::fromString(req).normalized(); - const auto current = QVersionNumber::fromString(qVersion()).normalized(); - if (current >= required) - return; - std::unique_ptr<QApplication> application; - if (!qApp) - application = std::make_unique<QApplication>(argc, argv); - const QString message = QApplication::tr("Application \"%1\" requires Qt %2, found Qt %3.") - .arg(qAppName(), required.toString(), current.toString()); - QMessageBox::critical(nullptr, QApplication::tr("Incompatible Qt Library Error"), - message, QMessageBox::Abort); - qFatal().noquote() << message; + Q_WIDGETS_EXPORT void _q_requireVersion(int, char *[], QAnyStringView); + _q_requireVersion(argc, argv, req); } #define QT_REQUIRE_VERSION(argc, argv, str) qRequireVersion(argc, argv, str); |