Make sure we always quote the qmldebug command line arguments

Change-Id: I5ce68c238e0ab05d19715659a9cc2161e51e1a7e
Task-number: QTCREATORBUG-20260
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2018-04-16 13:42:43 +02:00
parent fa11070977
commit 17d530d60d
5 changed files with 39 additions and 14 deletions

View File

@@ -477,16 +477,16 @@ void DebuggerRunTool::setCoreFileName(const QString &coreFile, bool isSnapshot)
void DebuggerRunTool::appendInferiorCommandLineArgument(const QString &arg) void DebuggerRunTool::appendInferiorCommandLineArgument(const QString &arg)
{ {
if (!m_runParameters.inferior.commandLineArguments.isEmpty()) QtcProcess::addArg(&m_runParameters.inferior.commandLineArguments, arg,
m_runParameters.inferior.commandLineArguments.append(' '); device() ? device()->osType() : HostOsInfo::hostOs());
m_runParameters.inferior.commandLineArguments.append(arg);
} }
void DebuggerRunTool::prependInferiorCommandLineArgument(const QString &arg) void DebuggerRunTool::prependInferiorCommandLineArgument(const QString &arg)
{ {
if (!m_runParameters.inferior.commandLineArguments.isEmpty()) if (!m_runParameters.inferior.commandLineArguments.isEmpty())
m_runParameters.inferior.commandLineArguments.prepend(' '); m_runParameters.inferior.commandLineArguments.prepend(' ');
m_runParameters.inferior.commandLineArguments.prepend(arg); m_runParameters.inferior.commandLineArguments.prepend(
QtcProcess::quoteArg(arg, device() ? device()->osType() : HostOsInfo::hostOs()));
} }
void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded() void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded()

View File

@@ -46,6 +46,7 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcfallthrough.h> #include <utils/qtcfallthrough.h>
#include <utils/qtcprocess.h>
#include <utils/url.h> #include <utils/url.h>
#include <QMessageBox> #include <QMessageBox>
@@ -254,8 +255,8 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool,
else else
QTC_CHECK(false); QTC_CHECK(false);
QString arguments = QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, QString arguments = Utils::QtcProcess::quoteArg(
code, true); QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, code, true));
if (!debuggee.commandLineArguments.isEmpty()) if (!debuggee.commandLineArguments.isEmpty())
arguments += ' ' + debuggee.commandLineArguments; arguments += ' ' + debuggee.commandLineArguments;

View File

@@ -31,6 +31,7 @@
#include <qmlprofiler/qmlprofilertool.h> #include <qmlprofiler/qmlprofilertool.h>
#include <utils/url.h> #include <utils/url.h>
#include <utils/temporaryfile.h>
#include <QtTest> #include <QtTest>
#include <QTcpServer> #include <QTcpServer>
@@ -148,6 +149,31 @@ void LocalQmlProfilerRunnerTest::testRunner()
runControl->initiateFinish(); runControl->initiateFinish();
QTRY_VERIFY(runControl.isNull()); QTRY_VERIFY(runControl.isNull());
QVERIFY(profiler.isNull()); QVERIFY(profiler.isNull());
debuggee.commandLineArguments = QString("-test QmlProfiler,");
serverUrl.setScheme(Utils::urlSocketScheme());
{
Utils::TemporaryFile file("file with spaces");
if (file.open())
serverUrl.setPath(file.fileName());
}
runControl = new ProjectExplorer::RunControl(nullptr,
ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee);
profiler = new LocalQmlProfilerSupport(&tool, runControl, serverUrl);
connectRunner();
runControl->initiateStart();
QTRY_VERIFY_WITH_TIMEOUT(running, 30000);
QTRY_VERIFY_WITH_TIMEOUT(!running, 30000);
QCOMPARE(startCount, 4);
QCOMPARE(stopCount, 4);
QCOMPARE(runCount, 3);
runControl->initiateFinish();
QTRY_VERIFY(runControl.isNull());
QVERIFY(profiler.isNull());
} }
void LocalQmlProfilerRunnerTest::testFindFreePort() void LocalQmlProfilerRunnerTest::testFindFreePort()

View File

@@ -75,11 +75,10 @@ void QnxQmlProfilerSupport::start()
serverUrl.setScheme("tcp"); serverUrl.setScheme("tcp");
m_profiler->recordData("QmlServerUrl", serverUrl); m_profiler->recordData("QmlServerUrl", serverUrl);
QString args = QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, qmlPort);
auto r = runnable().as<StandardRunnable>(); auto r = runnable().as<StandardRunnable>();
if (!r.commandLineArguments.isEmpty()) QtcProcess::addArg(&r.commandLineArguments,
r.commandLineArguments.append(' '); QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, qmlPort),
r.commandLineArguments += args; device()->osType());
setRunnable(r); setRunnable(r);

View File

@@ -28,6 +28,7 @@
#include <projectexplorer/runnables.h> #include <projectexplorer/runnables.h>
#include <ssh/sshconnection.h> #include <ssh/sshconnection.h>
#include <utils/qtcprocess.h>
#include <utils/url.h> #include <utils/url.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -66,11 +67,9 @@ void RemoteLinuxQmlToolingSupport::start()
serverUrl.setPort(qmlPort.number()); serverUrl.setPort(qmlPort.number());
m_runworker->recordData("QmlServerUrl", serverUrl); m_runworker->recordData("QmlServerUrl", serverUrl);
QString args = QmlDebug::qmlDebugTcpArguments(m_services, qmlPort);
auto r = runnable().as<StandardRunnable>(); auto r = runnable().as<StandardRunnable>();
if (!r.commandLineArguments.isEmpty()) QtcProcess::addArg(&r.commandLineArguments, QmlDebug::qmlDebugTcpArguments(m_services, qmlPort),
r.commandLineArguments.append(' '); device()->osType());
r.commandLineArguments += args;
setRunnable(r); setRunnable(r);