diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 741a295af2d..b9c829a27d4 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -477,16 +477,16 @@ void DebuggerRunTool::setCoreFileName(const QString &coreFile, bool isSnapshot) void DebuggerRunTool::appendInferiorCommandLineArgument(const QString &arg) { - if (!m_runParameters.inferior.commandLineArguments.isEmpty()) - m_runParameters.inferior.commandLineArguments.append(' '); - m_runParameters.inferior.commandLineArguments.append(arg); + QtcProcess::addArg(&m_runParameters.inferior.commandLineArguments, arg, + device() ? device()->osType() : HostOsInfo::hostOs()); } void DebuggerRunTool::prependInferiorCommandLineArgument(const QString &arg) { if (!m_runParameters.inferior.commandLineArguments.isEmpty()) 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() diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index ff828ae11e5..e813ce0e612 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #include @@ -254,8 +255,8 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool, else QTC_CHECK(false); - QString arguments = QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, - code, true); + QString arguments = Utils::QtcProcess::quoteArg( + QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, code, true)); if (!debuggee.commandLineArguments.isEmpty()) arguments += ' ' + debuggee.commandLineArguments; diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index 007dac486a2..1f2dcce4b2f 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -148,6 +149,31 @@ void LocalQmlProfilerRunnerTest::testRunner() runControl->initiateFinish(); QTRY_VERIFY(runControl.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() diff --git a/src/plugins/qnx/qnxanalyzesupport.cpp b/src/plugins/qnx/qnxanalyzesupport.cpp index 8001327dedd..fa6a61b2672 100644 --- a/src/plugins/qnx/qnxanalyzesupport.cpp +++ b/src/plugins/qnx/qnxanalyzesupport.cpp @@ -75,11 +75,10 @@ void QnxQmlProfilerSupport::start() serverUrl.setScheme("tcp"); m_profiler->recordData("QmlServerUrl", serverUrl); - QString args = QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, qmlPort); auto r = runnable().as(); - if (!r.commandLineArguments.isEmpty()) - r.commandLineArguments.append(' '); - r.commandLineArguments += args; + QtcProcess::addArg(&r.commandLineArguments, + QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, qmlPort), + device()->osType()); setRunnable(r); diff --git a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp index 836ab11fd56..933c91f4762 100644 --- a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp @@ -28,6 +28,7 @@ #include #include +#include #include using namespace ProjectExplorer; @@ -66,11 +67,9 @@ void RemoteLinuxQmlToolingSupport::start() serverUrl.setPort(qmlPort.number()); m_runworker->recordData("QmlServerUrl", serverUrl); - QString args = QmlDebug::qmlDebugTcpArguments(m_services, qmlPort); auto r = runnable().as(); - if (!r.commandLineArguments.isEmpty()) - r.commandLineArguments.append(' '); - r.commandLineArguments += args; + QtcProcess::addArg(&r.commandLineArguments, QmlDebug::qmlDebugTcpArguments(m_services, qmlPort), + device()->osType()); setRunnable(r);