diff options
Diffstat (limited to 'src/plugins')
6 files changed, 29 insertions, 18 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp index 5108b7bd24..2b919e7f42 100644 --- a/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerclientmanager.cpp @@ -168,7 +168,7 @@ void QmlProfilerClientManager::retryConnect() { if (m_server.scheme() == "socket") { startLocalServer(); - } else if (!m_server.host().isEmpty() && m_server.port() > -1) { + } else if (!m_server.host().isEmpty() && m_server.port() > 0) { disconnectClient(); connectToTcpServer(); } else { diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index 3c7d65b2bf..81bb0fc267 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -63,6 +63,8 @@ using namespace QmlProfiler::Internal; namespace QmlProfiler { +static QString QmlServerUrl = "QmlServerUrl"; + // // QmlProfilerRunControlPrivate // @@ -72,8 +74,7 @@ class QmlProfilerRunner::QmlProfilerRunnerPrivate public: QmlProfilerStateManager *m_profilerState = 0; QTimer m_noDebugOutputTimer; - bool m_isLocal = false; - QUrl m_serverUrl; + bool m_isAutoStart = false; ProjectExplorer::ApplicationLauncher m_launcher; QmlDebug::QmlOutputParser m_outputParser; }; @@ -86,6 +87,7 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl) : RunWorker(runControl) , d(new QmlProfilerRunnerPrivate) { + setDisplayName("QmlProfilerRunner"); runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR); runControl->setSupportsReRunning(false); @@ -110,8 +112,7 @@ void QmlProfilerRunner::start() Internal::QmlProfilerTool::instance()->finalizeRunControl(this); QTC_ASSERT(d->m_profilerState, return); - QTC_ASSERT(connection().is<UrlConnection>(), return); - QUrl serverUrl = connection().as<UrlConnection>(); + QUrl serverUrl = this->serverUrl(); if (serverUrl.port() != -1) { auto clientManager = Internal::QmlProfilerTool::clientManager(); @@ -123,11 +124,9 @@ void QmlProfilerRunner::start() d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning); - if (d->m_isLocal) { - QTC_ASSERT(!d->m_serverUrl.path().isEmpty() || d->m_serverUrl.port() != -1, return); - + if (d->m_isAutoStart) { StandardRunnable debuggee = runnable().as<StandardRunnable>(); - QString arguments = QmlDebug::qmlDebugArguments(QmlDebug::QmlProfilerServices, d->m_serverUrl); + QString arguments = QmlDebug::qmlDebugArguments(QmlDebug::QmlProfilerServices, serverUrl); if (!debuggee.commandLineArguments.isEmpty()) arguments += ' ' + debuggee.commandLineArguments; @@ -243,8 +242,7 @@ void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port) { d->m_noDebugOutputTimer.stop(); - QTC_ASSERT(connection().is<UrlConnection>(), return); - QUrl serverUrl = connection().as<UrlConnection>(); + QUrl serverUrl = this->serverUrl(); if (!port.isValid()) port = Utils::Port(serverUrl.port()); @@ -284,8 +282,21 @@ void QmlProfilerRunner::profilerStateChanged() void QmlProfilerRunner::setServerUrl(const QUrl &serverUrl) { - d->m_isLocal = true; - d->m_serverUrl = serverUrl; + recordData(QmlServerUrl, serverUrl); +} + +QUrl QmlProfilerRunner::serverUrl() const +{ + QVariant recordedServer = recordedData(QmlServerUrl); + if (recordedServer.isValid()) + return recordedServer.toUrl(); + QTC_ASSERT(connection().is<UrlConnection>(), return QUrl()); + return connection().as<UrlConnection>(); +} + +void QmlProfilerRunner::setAutoStart() +{ + d->m_isAutoStart = true; connect(&d->m_launcher, &ApplicationLauncher::appendMessage, this, &QmlProfilerRunner::appendMessage); connect(this, &QmlProfilerRunner::localRunnerStopped, diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h index beea00b51d..e65b6ec2cf 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.h @@ -46,6 +46,7 @@ public: ~QmlProfilerRunner() override; void setServerUrl(const QUrl &serverUrl); + QUrl serverUrl() const; void registerProfilerStateManager( QmlProfilerStateManager *profilerState ); @@ -53,6 +54,7 @@ public: void notifyRemoteSetupFailed(const QString &errorMessage); void cancelProcess(); void notifyRemoteFinished(); + void setAutoStart(); signals: void localRunnerStarted(); diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp index e59a58d8cf..4484b7d965 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp @@ -90,6 +90,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat auto runner = new QmlProfilerRunner(runControl); runner->setServerUrl(serverUrl); + runner->setAutoStart(); return runControl; } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index c7529101d6..97fc6854ca 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -351,9 +351,8 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker) runWorker->registerProfilerStateManager(d->m_profilerState); QmlProfilerClientManager *clientManager = d->m_profilerConnections; - QTC_ASSERT(runWorker->connection().is<UrlConnection>(), return); // FIXME: Check that there's something sensible in sp.connParams - auto serverUrl = runWorker->connection().as<UrlConnection>(); + auto serverUrl = runWorker->serverUrl(); clientManager->setServerUrl(serverUrl); if (!serverUrl.path().isEmpty()) { // That's the local socket case. diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index 739ce2e522..ccc6b309ee 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -45,6 +45,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec void LocalQmlProfilerRunnerTest::connectRunner(QmlProfilerRunner *runner) { + runner->setAutoStart(); connect(runner, &QmlProfilerRunner::localRunnerStarted, this, [this] { QVERIFY(!running); ++runCount; @@ -66,7 +67,6 @@ void LocalQmlProfilerRunnerTest::testRunner() rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc->setRunnable(debuggee); - rc->setConnection(UrlConnection(serverUrl)); auto runner = new QmlProfilerRunner(rc); runner->setServerUrl(serverUrl); connectRunner(runner); @@ -89,7 +89,6 @@ void LocalQmlProfilerRunnerTest::testRunner1() delete rc; rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc->setRunnable(debuggee); - rc->setConnection(serverUrl); auto runner = new QmlProfilerRunner(rc); runner->setServerUrl(serverUrl); connectRunner(runner); @@ -108,7 +107,6 @@ void LocalQmlProfilerRunnerTest::testRunner2() serverUrl = UrlConnection::localHostAndFreePort(); rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc->setRunnable(debuggee); - rc->setConnection(serverUrl); auto runner = new QmlProfilerRunner(rc); runner->setServerUrl(serverUrl); connectRunner(runner); |