Commit 232fb7a4 authored by hjk's avatar hjk

QmlProfiler: Split server url passing from custom startup request

Orthogonal concepts, that only happen to coincide.

Also, make the server directly settable instead of relying
on the runControl's connection().

Change-Id: I2472acafcc50aede2cb6f99421901f0e67531b91
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 923c20bd
...@@ -168,7 +168,7 @@ void QmlProfilerClientManager::retryConnect() ...@@ -168,7 +168,7 @@ void QmlProfilerClientManager::retryConnect()
{ {
if (m_server.scheme() == "socket") { if (m_server.scheme() == "socket") {
startLocalServer(); startLocalServer();
} else if (!m_server.host().isEmpty() && m_server.port() > -1) { } else if (!m_server.host().isEmpty() && m_server.port() > 0) {
disconnectClient(); disconnectClient();
connectToTcpServer(); connectToTcpServer();
} else { } else {
......
...@@ -63,6 +63,8 @@ using namespace QmlProfiler::Internal; ...@@ -63,6 +63,8 @@ using namespace QmlProfiler::Internal;
namespace QmlProfiler { namespace QmlProfiler {
static QString QmlServerUrl = "QmlServerUrl";
// //
// QmlProfilerRunControlPrivate // QmlProfilerRunControlPrivate
// //
...@@ -72,8 +74,7 @@ class QmlProfilerRunner::QmlProfilerRunnerPrivate ...@@ -72,8 +74,7 @@ class QmlProfilerRunner::QmlProfilerRunnerPrivate
public: public:
QmlProfilerStateManager *m_profilerState = 0; QmlProfilerStateManager *m_profilerState = 0;
QTimer m_noDebugOutputTimer; QTimer m_noDebugOutputTimer;
bool m_isLocal = false; bool m_isAutoStart = false;
QUrl m_serverUrl;
ProjectExplorer::ApplicationLauncher m_launcher; ProjectExplorer::ApplicationLauncher m_launcher;
QmlDebug::QmlOutputParser m_outputParser; QmlDebug::QmlOutputParser m_outputParser;
}; };
...@@ -86,6 +87,7 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl) ...@@ -86,6 +87,7 @@ QmlProfilerRunner::QmlProfilerRunner(RunControl *runControl)
: RunWorker(runControl) : RunWorker(runControl)
, d(new QmlProfilerRunnerPrivate) , d(new QmlProfilerRunnerPrivate)
{ {
setDisplayName("QmlProfilerRunner");
runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR); runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
runControl->setSupportsReRunning(false); runControl->setSupportsReRunning(false);
...@@ -110,8 +112,7 @@ void QmlProfilerRunner::start() ...@@ -110,8 +112,7 @@ void QmlProfilerRunner::start()
Internal::QmlProfilerTool::instance()->finalizeRunControl(this); Internal::QmlProfilerTool::instance()->finalizeRunControl(this);
QTC_ASSERT(d->m_profilerState, return); QTC_ASSERT(d->m_profilerState, return);
QTC_ASSERT(connection().is<UrlConnection>(), return); QUrl serverUrl = this->serverUrl();
QUrl serverUrl = connection().as<UrlConnection>();
if (serverUrl.port() != -1) { if (serverUrl.port() != -1) {
auto clientManager = Internal::QmlProfilerTool::clientManager(); auto clientManager = Internal::QmlProfilerTool::clientManager();
...@@ -123,11 +124,9 @@ void QmlProfilerRunner::start() ...@@ -123,11 +124,9 @@ void QmlProfilerRunner::start()
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning); d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);
if (d->m_isLocal) { if (d->m_isAutoStart) {
QTC_ASSERT(!d->m_serverUrl.path().isEmpty() || d->m_serverUrl.port() != -1, return);
StandardRunnable debuggee = runnable().as<StandardRunnable>(); 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()) if (!debuggee.commandLineArguments.isEmpty())
arguments += ' ' + debuggee.commandLineArguments; arguments += ' ' + debuggee.commandLineArguments;
...@@ -243,8 +242,7 @@ void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port) ...@@ -243,8 +242,7 @@ void QmlProfilerRunner::notifyRemoteSetupDone(Utils::Port port)
{ {
d->m_noDebugOutputTimer.stop(); d->m_noDebugOutputTimer.stop();
QTC_ASSERT(connection().is<UrlConnection>(), return); QUrl serverUrl = this->serverUrl();
QUrl serverUrl = connection().as<UrlConnection>();
if (!port.isValid()) if (!port.isValid())
port = Utils::Port(serverUrl.port()); port = Utils::Port(serverUrl.port());
...@@ -284,8 +282,21 @@ void QmlProfilerRunner::profilerStateChanged() ...@@ -284,8 +282,21 @@ void QmlProfilerRunner::profilerStateChanged()
void QmlProfilerRunner::setServerUrl(const QUrl &serverUrl) void QmlProfilerRunner::setServerUrl(const QUrl &serverUrl)
{ {
d->m_isLocal = true; recordData(QmlServerUrl, serverUrl);
d->m_serverUrl = 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, connect(&d->m_launcher, &ApplicationLauncher::appendMessage,
this, &QmlProfilerRunner::appendMessage); this, &QmlProfilerRunner::appendMessage);
connect(this, &QmlProfilerRunner::localRunnerStopped, connect(this, &QmlProfilerRunner::localRunnerStopped,
......
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
~QmlProfilerRunner() override; ~QmlProfilerRunner() override;
void setServerUrl(const QUrl &serverUrl); void setServerUrl(const QUrl &serverUrl);
QUrl serverUrl() const;
void registerProfilerStateManager( QmlProfilerStateManager *profilerState ); void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
...@@ -53,6 +54,7 @@ public: ...@@ -53,6 +54,7 @@ public:
void notifyRemoteSetupFailed(const QString &errorMessage); void notifyRemoteSetupFailed(const QString &errorMessage);
void cancelProcess(); void cancelProcess();
void notifyRemoteFinished(); void notifyRemoteFinished();
void setAutoStart();
signals: signals:
void localRunnerStarted(); void localRunnerStarted();
......
...@@ -90,6 +90,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat ...@@ -90,6 +90,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
auto runner = new QmlProfilerRunner(runControl); auto runner = new QmlProfilerRunner(runControl);
runner->setServerUrl(serverUrl); runner->setServerUrl(serverUrl);
runner->setAutoStart();
return runControl; return runControl;
} }
......
...@@ -351,9 +351,8 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker) ...@@ -351,9 +351,8 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
runWorker->registerProfilerStateManager(d->m_profilerState); runWorker->registerProfilerStateManager(d->m_profilerState);
QmlProfilerClientManager *clientManager = d->m_profilerConnections; QmlProfilerClientManager *clientManager = d->m_profilerConnections;
QTC_ASSERT(runWorker->connection().is<UrlConnection>(), return);
// FIXME: Check that there's something sensible in sp.connParams // FIXME: Check that there's something sensible in sp.connParams
auto serverUrl = runWorker->connection().as<UrlConnection>(); auto serverUrl = runWorker->serverUrl();
clientManager->setServerUrl(serverUrl); clientManager->setServerUrl(serverUrl);
if (!serverUrl.path().isEmpty()) { if (!serverUrl.path().isEmpty()) {
// That's the local socket case. // That's the local socket case.
......
...@@ -45,6 +45,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec ...@@ -45,6 +45,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
void LocalQmlProfilerRunnerTest::connectRunner(QmlProfilerRunner *runner) void LocalQmlProfilerRunnerTest::connectRunner(QmlProfilerRunner *runner)
{ {
runner->setAutoStart();
connect(runner, &QmlProfilerRunner::localRunnerStarted, this, [this] { connect(runner, &QmlProfilerRunner::localRunnerStarted, this, [this] {
QVERIFY(!running); QVERIFY(!running);
++runCount; ++runCount;
...@@ -66,7 +67,6 @@ void LocalQmlProfilerRunnerTest::testRunner() ...@@ -66,7 +67,6 @@ void LocalQmlProfilerRunnerTest::testRunner()
rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
rc->setRunnable(debuggee); rc->setRunnable(debuggee);
rc->setConnection(UrlConnection(serverUrl));
auto runner = new QmlProfilerRunner(rc); auto runner = new QmlProfilerRunner(rc);
runner->setServerUrl(serverUrl); runner->setServerUrl(serverUrl);
connectRunner(runner); connectRunner(runner);
...@@ -89,7 +89,6 @@ void LocalQmlProfilerRunnerTest::testRunner1() ...@@ -89,7 +89,6 @@ void LocalQmlProfilerRunnerTest::testRunner1()
delete rc; delete rc;
rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
rc->setRunnable(debuggee); rc->setRunnable(debuggee);
rc->setConnection(serverUrl);
auto runner = new QmlProfilerRunner(rc); auto runner = new QmlProfilerRunner(rc);
runner->setServerUrl(serverUrl); runner->setServerUrl(serverUrl);
connectRunner(runner); connectRunner(runner);
...@@ -108,7 +107,6 @@ void LocalQmlProfilerRunnerTest::testRunner2() ...@@ -108,7 +107,6 @@ void LocalQmlProfilerRunnerTest::testRunner2()
serverUrl = UrlConnection::localHostAndFreePort(); serverUrl = UrlConnection::localHostAndFreePort();
rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); rc = new ProjectExplorer::RunControl(nullptr, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
rc->setRunnable(debuggee); rc->setRunnable(debuggee);
rc->setConnection(serverUrl);
auto runner = new QmlProfilerRunner(rc); auto runner = new QmlProfilerRunner(rc);
runner->setServerUrl(serverUrl); runner->setServerUrl(serverUrl);
connectRunner(runner); connectRunner(runner);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment