From 9db6c67f5ce375ff14ad7576b67c6e96bc73b080 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 31 Jan 2014 09:49:58 +0100 Subject: [PATCH] Support --option in addition to -option for all builtin Qt commandline options. In addition to being more common and consistent with QCommandLineParser, this will make it possible to add the documentation for these options in the QCommandLineParser-generated help output. [ChangeLog][General] Builtin command-line options such as -reverse, -session, -style etc. now all support double dash, e.g. --reverse, --session, --style... Change-Id: Ia2e22c854ccc6a9d7b863b1234317005bc822191 Reviewed-by: Thiago Macieira Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qcoreapplication.cpp | 2 ++ src/gui/kernel/qguiapplication.cpp | 4 ++++ src/plugins/platforms/xcb/qxcbintegration.cpp | 21 ++++++++----------- src/widgets/kernel/qapplication.cpp | 3 ++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 3118034b88..d5d964eaec 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -186,6 +186,8 @@ void QCoreApplicationPrivate::processCommandLineArguments() continue; } QByteArray arg = argv[i]; + if (arg.startsWith("--")) + arg.remove(0, 1); if (arg.startsWith("-qmljsdebugger=")) { qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15)); } else if (arg == "-qmljsdebugger" && i < argc - 1) { diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 5cfe034dbe..32f2b20940 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1018,6 +1018,8 @@ void QGuiApplicationPrivate::createPlatformIntegration() continue; } QByteArray arg = argv[i]; + if (arg.startsWith("--")) + arg.remove(0, 1); if (arg == "-platformpluginpath") { if (++i < argc) platformPluginPath = QLatin1String(argv[i]); @@ -1098,6 +1100,8 @@ void QGuiApplicationPrivate::init() continue; } QByteArray arg = argv[i]; + if (arg.startsWith("--")) + arg.remove(0, 1); if (arg == "-plugin") { if (++i < argc) pluginList << argv[i]; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index ecbf28bab9..1803282071 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -145,18 +145,15 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char if (argc) { int j = 1; for (int i = 1; i < argc; i++) { - char *arg = argv[i]; - if (arg) { - if (!strcmp(arg, "-display") && i < argc - 1) { - displayName = argv[++i]; - arg = 0; - } else if (!strcmp(arg, "-name") && i < argc - 1) { - m_instanceName = argv[++i]; - arg = 0; - } - } - if (arg) - argv[j++] = arg; + QByteArray arg(argv[i]); + if (arg.startsWith("--")) + arg.remove(0, 1); + if (arg == "-display" && i < argc - 1) + displayName = argv[++i]; + else if (arg == "-name" && i < argc - 1) + m_instanceName = argv[++i]; + else + argv[j++] = argv[i]; } argc = j; } // argc diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 1f84a4b5c4..fdf0fcdbdb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -446,7 +446,8 @@ void QApplicationPrivate::process_cmdline() continue; } QByteArray arg = argv[i]; - arg = arg; + if (arg.startsWith("--")) + arg.remove(0, 1); QString s; if (arg == "-qdevel" || arg == "-qdebug") { // obsolete argument