Inline qcorecmdlineargs_p.h into qcoreapplication.cpp
... its only remaining user. Amends 71b54cc24431e8bc6e97f5d62132bd5261764c3a, which removed the only remaining non-qcoreapplication.cpp user of qWinCmdArgs(). In the process, rename the function to non-public-API-looking winCmdArgs(), and adjust its Q_OS_ protection to what its caller uses (Q_OS_WIN; was: Q_OS_WIN32). As a drive-by, change an old-style- to reinterpret_cast. Task-number: QTBUG-126219 Change-Id: Id37e62e9df2a0c44bb1e446e409fd36e11cb77ce Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit c59ebcfe72d1416897f251036db34902bbb39b1a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1f0cf1e6e5
commit
1939eba8a3
@ -152,7 +152,6 @@ qt_internal_add_module(Core
|
|||||||
kernel/qchronotimer.cpp kernel/qchronotimer.h
|
kernel/qchronotimer.cpp kernel/qchronotimer.h
|
||||||
kernel/qcoreapplication.cpp kernel/qcoreapplication.h kernel/qcoreapplication_p.h
|
kernel/qcoreapplication.cpp kernel/qcoreapplication.h kernel/qcoreapplication_p.h
|
||||||
kernel/qcoreapplication_platform.h
|
kernel/qcoreapplication_platform.h
|
||||||
kernel/qcorecmdlineargs_p.h
|
|
||||||
kernel/qcoreevent.cpp kernel/qcoreevent.h kernel/qcoreevent_p.h
|
kernel/qcoreevent.cpp kernel/qcoreevent.h kernel/qcoreevent_p.h
|
||||||
kernel/qdeadlinetimer.cpp kernel/qdeadlinetimer.h
|
kernel/qdeadlinetimer.cpp kernel/qdeadlinetimer.h
|
||||||
kernel/qelapsedtimer.cpp kernel/qelapsedtimer.h
|
kernel/qelapsedtimer.cpp kernel/qelapsedtimer.h
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "qmetaobject.h"
|
#include "qmetaobject.h"
|
||||||
#include <private/qproperty_p.h>
|
#include <private/qproperty_p.h>
|
||||||
#include "qcorecmdlineargs_p.h"
|
|
||||||
#include <qdatastream.h>
|
#include <qdatastream.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
@ -110,6 +109,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
# include <qt_windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
#ifndef QT_NO_QOBJECT
|
#ifndef QT_NO_QOBJECT
|
||||||
@ -2581,6 +2584,22 @@ qint64 QCoreApplication::applicationPid()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
static inline QStringList winCmdArgs(const QString &cmdLine)
|
||||||
|
{
|
||||||
|
QStringList result;
|
||||||
|
int size;
|
||||||
|
if (wchar_t **argv = CommandLineToArgvW(reinterpret_cast<const wchar_t *>(cmdLine.utf16()), &size)) {
|
||||||
|
result.reserve(size);
|
||||||
|
wchar_t **argvEnd = argv + size;
|
||||||
|
for (wchar_t **a = argv; a < argvEnd; ++a)
|
||||||
|
result.append(QString::fromWCharArray(*a));
|
||||||
|
LocalFree(argv);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.1
|
\since 4.1
|
||||||
|
|
||||||
@ -2636,7 +2655,7 @@ QStringList QCoreApplication::arguments()
|
|||||||
// the Windows API instead of using argv. Note that we only
|
// the Windows API instead of using argv. Note that we only
|
||||||
// do this when argv were not modified by the user in main().
|
// do this when argv were not modified by the user in main().
|
||||||
QString cmdline = QString::fromWCharArray(GetCommandLine());
|
QString cmdline = QString::fromWCharArray(GetCommandLine());
|
||||||
QStringList commandLineArguments = qWinCmdArgs(cmdline);
|
QStringList commandLineArguments = winCmdArgs(cmdline);
|
||||||
|
|
||||||
// Even if the user didn't modify argv before passing them
|
// Even if the user didn't modify argv before passing them
|
||||||
// on to QCoreApplication, derived QApplications might have.
|
// on to QCoreApplication, derived QApplications might have.
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
|
||||||
|
|
||||||
#ifndef QCORECMDLINEARGS_P_H
|
|
||||||
#define QCORECMDLINEARGS_P_H
|
|
||||||
|
|
||||||
//
|
|
||||||
// W A R N I N G
|
|
||||||
// -------------
|
|
||||||
//
|
|
||||||
// This file is not part of the Qt API. It exists purely as an
|
|
||||||
// implementation detail. This header file may change from version to
|
|
||||||
// version without notice, or even be removed.
|
|
||||||
//
|
|
||||||
// We mean it.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <QtCore/private/qglobal_p.h>
|
|
||||||
#include "QtCore/qstring.h"
|
|
||||||
#include "QtCore/qstringlist.h"
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
# ifdef Q_OS_WIN32
|
|
||||||
# include <qt_windows.h> // first to suppress min, max macros.
|
|
||||||
# include <shlobj.h>
|
|
||||||
# else
|
|
||||||
# include <qt_windows.h>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
|
||||||
|
|
||||||
static inline QStringList qWinCmdArgs(const QString &cmdLine)
|
|
||||||
{
|
|
||||||
QStringList result;
|
|
||||||
int size;
|
|
||||||
if (wchar_t **argv = CommandLineToArgvW((const wchar_t *)cmdLine.utf16(), &size)) {
|
|
||||||
result.reserve(size);
|
|
||||||
wchar_t **argvEnd = argv + size;
|
|
||||||
for (wchar_t **a = argv; a < argvEnd; ++a)
|
|
||||||
result.append(QString::fromWCharArray(*a));
|
|
||||||
LocalFree(argv);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // Q_OS_WIN32
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // Q_OS_WIN
|
|
||||||
|
|
||||||
#endif // QCORECMDLINEARGS_WIN_P_H
|
|
Loading…
x
Reference in New Issue
Block a user