From 0e528f2976a64d0348fe0bebfb97293eae5bac73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Keller?= Date: Tue, 28 Nov 2023 11:22:04 +0100 Subject: Windeployqt: Fix -v/--version option While the version option was already there, it had no output attached to it, and simply generated the whole help text. Make sure that if the -v/--version option is set, only the tool version is outputted. Fixes: QTBUG-119511 Pick-to: 6.6 Change-Id: I59ee620333c02eb0a031cd05ac3170216cd034fa Reviewed-by: Oliver Wolff --- src/tools/windeployqt/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tools/windeployqt/main.cpp b/src/tools/windeployqt/main.cpp index f3c579c56b..cc9a3f88dd 100644 --- a/src/tools/windeployqt/main.cpp +++ b/src/tools/windeployqt/main.cpp @@ -229,7 +229,8 @@ static QString msgFileDoesNotExist(const QString & file) enum CommandLineParseFlag { CommandLineParseError = 0x1, - CommandLineParseHelpRequested = 0x2 + CommandLineParseHelpRequested = 0x2, + CommandLineVersionRequested = 0x4 }; static QCommandLineOption createQMakeOption() @@ -330,7 +331,7 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse "installation (e.g. ) to the PATH variable and then run:\n windeployqt \n\n" "If your application uses Qt Quick, run:\n windeployqt --qmldir "_s); const QCommandLineOption helpOption = parser->addHelpOption(); - parser->addVersionOption(); + const QCommandLineOption versionOption = parser->addVersionOption(); QCommandLineOption dirOption(QStringLiteral("dir"), QStringLiteral("Use directory instead of binary directory."), @@ -520,6 +521,8 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse const bool success = parser->parse(arguments); if (parser->isSet(helpOption)) return CommandLineParseHelpRequested; + if (parser->isSet(versionOption)) + return CommandLineVersionRequested; if (!success) { *errorMessage = parser->errorText(); return CommandLineParseError; @@ -1810,6 +1813,10 @@ int main(int argc, char **argv) const int result = parseArguments(QCoreApplication::arguments(), &parser, &options, &errorMessage); if (result & CommandLineParseError) std::wcerr << errorMessage << "\n\n"; + if (result & CommandLineVersionRequested) { + std::fputs(QT_VERSION_STR "\n", stdout); + return 0; + } if (result & CommandLineParseHelpRequested) std::fputs(qPrintable(helpText(parser, pluginInfo)), stdout); if (result & CommandLineParseError) -- cgit v1.2.3