QMessageBox: Remove include of qdebug.h
Move the implementation qRequireVersion() to prevent having to include qdebug.h which pulls in many other headers. Amendsb5d874e36f
. Fix missing include introduced by3a553507a1
. 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>
This commit is contained in:
parent
684070bc34
commit
408fbd3f2d
@ -4,6 +4,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "xbeltree.h"
|
#include "xbeltree.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -30,11 +30,17 @@
|
|||||||
#include "private/qabstractbutton_p.h"
|
#include "private/qabstractbutton_p.h"
|
||||||
#include <QtGui/qpa/qplatformtheme.h>
|
#include <QtGui/qpa/qplatformtheme.h>
|
||||||
|
|
||||||
|
#include <QtCore/qanystringview.h>
|
||||||
|
#include <QtCore/qdebug.h>
|
||||||
|
#include <QtCore/qversionnumber.h>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# include <QtCore/qt_windows.h>
|
# include <QtCore/qt_windows.h>
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
@ -2841,6 +2847,22 @@ void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHel
|
|||||||
clickedButton = button;
|
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)
|
#if QT_DEPRECATED_SINCE(6,2)
|
||||||
/*!
|
/*!
|
||||||
\deprecated
|
\deprecated
|
||||||
|
@ -5,17 +5,13 @@
|
|||||||
#define QMESSAGEBOX_H
|
#define QMESSAGEBOX_H
|
||||||
|
|
||||||
#include <QtWidgets/qtwidgetsglobal.h>
|
#include <QtWidgets/qtwidgetsglobal.h>
|
||||||
#include <QtWidgets/qapplication.h>
|
|
||||||
#include <QtWidgets/qdialog.h>
|
#include <QtWidgets/qdialog.h>
|
||||||
|
|
||||||
#include <QtCore/qanystringview.h>
|
|
||||||
#include <QtCore/qdebug.h>
|
|
||||||
#include <QtCore/qversionnumber.h>
|
|
||||||
|
|
||||||
QT_REQUIRE_CONFIG(messagebox);
|
QT_REQUIRE_CONFIG(messagebox);
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QAnyStringView;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QMessageBoxPrivate;
|
class QMessageBoxPrivate;
|
||||||
class QAbstractButton;
|
class QAbstractButton;
|
||||||
@ -319,18 +315,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QMessageBox::StandardButtons)
|
|||||||
[[maybe_unused]]
|
[[maybe_unused]]
|
||||||
static inline void qRequireVersion(int argc, char *argv[], QAnyStringView req)
|
static inline void qRequireVersion(int argc, char *argv[], QAnyStringView req)
|
||||||
{
|
{
|
||||||
const auto required = QVersionNumber::fromString(req).normalized();
|
Q_WIDGETS_EXPORT void _q_requireVersion(int, char *[], QAnyStringView);
|
||||||
const auto current = QVersionNumber::fromString(qVersion()).normalized();
|
_q_requireVersion(argc, argv, req);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define QT_REQUIRE_VERSION(argc, argv, str) qRequireVersion(argc, argv, str);
|
#define QT_REQUIRE_VERSION(argc, argv, str) qRequireVersion(argc, argv, str);
|
||||||
|
Loading…
Reference in New Issue
Block a user