From cc2213ab271cfdaa312c3ba93dff0a294d7e11f3 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 16 Dec 2024 11:59:46 +0100 Subject: [PATCH] Change QCommandLineParser::showMessageAndExit() argument order Looking at other similar Qt APIs, the type argument usually comes first. The typical related examples can be QMessageBox() constructor taking QIcon as a first parameter, and qFormatLogMessage() function, taking message type as a first parameter. This patch changes the order of arguments, so that MessageType enum comes as a first argument. Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480. Found in Qt 6.9 API review. Change-Id: Ibbdef755a8676a2c556fe7f1c95009ad51320b98 Reviewed-by: David Faure (cherry picked from commit 56114f4d1ed6ec26ff59a596caf09f5b4e0f5d68) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qcommandlineparser.cpp | 17 ++++++++++------- src/corelib/tools/qcommandlineparser.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 0f421d57438..45831d093d7 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -562,7 +562,7 @@ static inline bool displayMessageBox() \sa addVersionOption(), showHelp(), showVersion(), QCommandLineParser::MessageType */ -Q_NORETURN void QCommandLineParser::showMessageAndExit(const QString &message, MessageType type, int exitCode) +Q_NORETURN void QCommandLineParser::showMessageAndExit(MessageType type, const QString &message, int exitCode) { #if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) if (displayMessageBox()) { @@ -601,8 +601,9 @@ Q_NORETURN void QCommandLineParser::showMessageAndExit(const QString &message, M void QCommandLineParser::process(const QStringList &arguments) { if (!d->parse(arguments)) { - showMessageAndExit(QCoreApplication::applicationName() + ": "_L1 + errorText() + u'\n', - ErrorMessage, EXIT_FAILURE); + showMessageAndExit(ErrorMessage, + QCoreApplication::applicationName() + ": "_L1 + errorText() + u'\n', + EXIT_FAILURE); } if (d->builtinVersionOption && isSet(QStringLiteral("version"))) @@ -1035,9 +1036,10 @@ QStringList QCommandLineParser::unknownOptionNames() const */ Q_NORETURN void QCommandLineParser::showVersion() { - showMessageAndExit(QCoreApplication::applicationName() + u' ' + showMessageAndExit(InformationMessage, + QCoreApplication::applicationName() + u' ' + QCoreApplication::applicationVersion() + u'\n', - InformationMessage, EXIT_SUCCESS); + EXIT_SUCCESS); } /*! @@ -1058,8 +1060,9 @@ Q_NORETURN void QCommandLineParser::showHelp(int exitCode) Q_NORETURN void QCommandLineParserPrivate::showHelp(int exitCode, bool includeQtOptions) { - QCommandLineParser::showMessageAndExit(helpText(includeQtOptions), - QCommandLineParser::InformationMessage, exitCode); + QCommandLineParser::showMessageAndExit(QCommandLineParser::InformationMessage, + helpText(includeQtOptions), + exitCode); } /*! diff --git a/src/corelib/tools/qcommandlineparser.h b/src/corelib/tools/qcommandlineparser.h index a15c2604fb6..1efcf41b578 100644 --- a/src/corelib/tools/qcommandlineparser.h +++ b/src/corelib/tools/qcommandlineparser.h @@ -71,7 +71,7 @@ public: InformationMessage, ErrorMessage, }; - Q_NORETURN static void showMessageAndExit(const QString &message, MessageType type, int exitCode = 0); + Q_NORETURN static void showMessageAndExit(MessageType type, const QString &message, int exitCode = 0); private: Q_DISABLE_COPY(QCommandLineParser)