diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index 43666ab5ff1..ec416eb38d1 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -142,45 +142,20 @@ void QmlProfilerRunner::profilerStateChanged() } } -// -// LocalQmlProfilerSupport -// - -static QUrl localServerUrl(RunControl *runControl) +RunWorker *createLocalQmlProfilerWorker(RunControl *runControl) { - QUrl serverUrl; - Kit *kit = runControl->kit(); - const QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit); - if (version) { - if (version->qtVersion() >= QVersionNumber(5, 6, 0)) - serverUrl = Utils::urlFromLocalSocket(); - else - serverUrl = Utils::urlFromLocalHostAndFreePort(); - } else { - qWarning("Running QML profiler on Kit without Qt version?"); - serverUrl = Utils::urlFromLocalHostAndFreePort(); - } - return serverUrl; -} + auto worker = new SimpleTargetRunner(runControl); -LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl) - : LocalQmlProfilerSupport(runControl, localServerUrl(runControl)) -{ -} - -LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const QUrl &serverUrl) - : SimpleTargetRunner(runControl) -{ - setId("LocalQmlProfilerSupport"); + worker->setId("LocalQmlProfilerSupport"); auto profiler = new QmlProfilerRunner(runControl); - addStopDependency(profiler); + worker->addStopDependency(profiler); // We need to open the local server before the application tries to connect. // In the TCP case, it doesn't hurt either to start the profiler before. - addStartDependency(profiler); + worker->addStartDependency(profiler); - setStartModifier([this, runControl, serverUrl] { + worker->setStartModifier([worker, runControl] { QUrl serverUrl = runControl->qmlChannel(); QString code; @@ -192,16 +167,17 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q QTC_CHECK(false); QString arguments = Utils::ProcessArgs::quoteArg( - qmlDebugCommandLineArguments(QmlProfilerServices, code, true)); + qmlDebugCommandLineArguments(QmlProfilerServices, code, true)); - Utils::CommandLine cmd = commandLine(); + Utils::CommandLine cmd = worker->commandLine(); const QString oldArgs = cmd.arguments(); cmd.setArguments(arguments); cmd.addArgs(oldArgs, Utils::CommandLine::Raw); - setCommandLine(cmd); - - forceRunOnHost(); + worker->setCommandLine(cmd); + worker->forceRunOnHost(); }); + + return worker; } // Factories @@ -224,7 +200,7 @@ public: LocalQmlProfilerRunWorkerFactory() { setId(ProjectExplorer::Constants::QML_PROFILER_RUN_FACTORY); - setProduct(); + setProducer(&createLocalQmlProfilerWorker); addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); @@ -238,5 +214,4 @@ void setupQmlProfilerRunning() static LocalQmlProfilerRunWorkerFactory theLocalQmlProfilerRunWorkerFactory; } - } // QmlProfiler::Internal diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index 424d8e1afc4..dcc374c9892 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -37,16 +37,7 @@ private: QmlProfilerRunnerPrivate *d; }; -class LocalQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner -{ - Q_OBJECT - -public: - LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl); - LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl, - const QUrl &serverUrl); -}; - +ProjectExplorer::RunWorker *createLocalQmlProfilerWorker(ProjectExplorer::RunControl *runControl); void setupQmlProfilerRunning(); } // QmlProfiler::Internal diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index a417775dbf6..94ea38a8fe7 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -29,8 +29,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec void LocalQmlProfilerRunnerTest::testRunner() { QPointer runControl; - QPointer profiler; - QUrl serverUrl; + QPointer profiler; bool running = false; bool started = false; @@ -38,14 +37,10 @@ void LocalQmlProfilerRunnerTest::testRunner() int runCount = 0; int stopCount = 0; - // should not be used anywhere but cannot be empty - serverUrl.setScheme(Utils::urlSocketScheme()); - serverUrl.setPath("invalid"); - runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl->setCommandLine(CommandLine{"\\-/|\\-/"}); - profiler = new LocalQmlProfilerSupport(runControl, serverUrl); + profiler = createLocalQmlProfilerWorker(runControl); auto connectRunner = [&]() { connect(runControl, &RunControl::aboutToStart, this, [&] { @@ -85,13 +80,12 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_VERIFY(runControl.isNull()); QVERIFY(profiler.isNull()); - serverUrl = Utils::urlFromLocalSocket(); // comma is used to specify a test function. In this case, an invalid one. runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); const FilePath app = FilePath::fromString(QCoreApplication::applicationFilePath()); runControl->setCommandLine({app, {"-test", "QmlProfiler,"}}); - profiler = new LocalQmlProfilerSupport(runControl, serverUrl); + profiler = createLocalQmlProfilerWorker(runControl); connectRunner(); runControl->initiateStart(); @@ -106,11 +100,9 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_VERIFY(runControl.isNull()); QVERIFY(profiler.isNull()); - serverUrl.clear(); - serverUrl = Utils::urlFromLocalHostAndFreePort(); runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl->setCommandLine(CommandLine{app}); - profiler = new LocalQmlProfilerSupport(runControl, serverUrl); + profiler = createLocalQmlProfilerWorker(runControl); connectRunner(); runControl->initiateStart(); @@ -126,16 +118,9 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_VERIFY(runControl.isNull()); QVERIFY(profiler.isNull()); - serverUrl.setScheme(Utils::urlSocketScheme()); - { - Utils::TemporaryFile file("file with spaces"); - if (file.open()) - serverUrl.setPath(file.fileName()); - } - runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl->setCommandLine({app, {"-test", "QmlProfiler,"}}); - profiler = new LocalQmlProfilerSupport(runControl, serverUrl); + profiler = createLocalQmlProfilerWorker(runControl); connectRunner(); runControl->initiateStart();