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()
{
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 {
......
......@@ -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,
......
......@@ -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();
......
......@@ -90,6 +90,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
auto runner = new QmlProfilerRunner(runControl);
runner->setServerUrl(serverUrl);
runner->setAutoStart();
return runControl;
}
......
......@@ -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.
......
......@@ -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);
......
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