diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-04-30 08:46:16 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-15 09:34:19 +0200 |
commit | 9b121e5579538477a1fc7c8250e5d7e875a58de8 (patch) | |
tree | 2971eedf712f52c299fca687f97ed552e333f9ac /src/corelib/kernel/qcoreapplication_win.cpp | |
parent | 9dc254ad5031a1335c163f156abfd573f11a935f (diff) |
Windows: Use WinAPI CommandLineToArgvW() to create argv from command line.
Split the Windows CE/Desktop Windows code paths in winmain.
Use CommandLineToArgvW() to obtain argv[] for Desktop Windows.
[ChangeLog][QtCore][Windows] Command line parsing on Windows
now uses the WinAPI function CommandLineToArgvW() to exactly
match the quoting of the command interpreter.
Task-number: QTBUG-35432
Task-number: QTBUG-23687
Change-Id: I6743e73649d953497642f7717d3731a83ffda2a2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication_win.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication_win.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 65ca6b0dcb..0ce3f00472 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch> -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -145,14 +145,30 @@ QString QCoreApplicationPrivate::appName() const qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp *****************************************************************************/ -#if defined(Q_OS_WINCE) -Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, - int cmdShow, int &argc, QVector<char *> &argv) -#else +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) + +// ### Qt6: FIXME: Remove this function. It is only there since for binary +// compatibility for applications built with Qt 5.3 using qtmain.lib which calls it. +// In Qt 5.4, qtmain.lib was changed to use CommandLineToArgvW() without calling into Qt5Core. Q_CORE_EXPORT void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, + int cmdShow, int &argc, QVector<char *> &argv) +{ + Q_UNUSED(instance) + Q_UNUSED(prevInstance) + Q_UNUSED(cmdShow) + + const QStringList wArgv = qWinCmdArgs(QString::fromLocal8Bit(cmdParam)); + argv.clear(); + argc = wArgv.size(); + foreach (const QString &wArg, wArgv) + argv.append(_strdup(wArg.toLocal8Bit().constData())); +} + +#elif defined(Q_OS_WINCE) + +Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, int cmdShow, int &argc, QVector<char *> &argv) -#endif { static bool already_called = false; @@ -172,6 +188,8 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, Q_UNUSED(prevInstance); } +#endif // Q_OS_WINCE + #ifndef QT_NO_QOBJECT void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId) |