QmlProfiler: Add members for QML port and host

Change-Id: If454497b87d84ce0f998edf7a99783ec833f352c
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
This commit is contained in:
Aurindam Jana
2013-04-22 17:11:06 +02:00
parent 5478cf3c78
commit 253a8522bb
3 changed files with 20 additions and 14 deletions

View File

@@ -61,6 +61,8 @@ public:
Utils::Environment environment; Utils::Environment environment;
QString workingDirectory; QString workingDirectory;
QString sysroot; QString sysroot;
QString analyzerHost;
quint16 analyzerPort;
}; };
} // namespace Analyzer } // namespace Analyzer

View File

@@ -66,11 +66,11 @@ namespace Internal {
class QmlProfilerEngine::QmlProfilerEnginePrivate class QmlProfilerEngine::QmlProfilerEnginePrivate
{ {
public: public:
QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {} QmlProfilerEnginePrivate(QmlProfilerEngine *qq, const AnalyzerStartParameters &sp) : q(qq), m_runner(0), sp(sp) {}
~QmlProfilerEnginePrivate() { delete m_runner; } ~QmlProfilerEnginePrivate() { delete m_runner; }
bool attach(const QString &address, uint port); bool attach(const QString &address, uint port);
static AbstractQmlProfilerRunner *createRunner(ProjectExplorer::RunConfiguration *runConfiguration, AbstractQmlProfilerRunner *createRunner(ProjectExplorer::RunConfiguration *runConfiguration,
QObject *parent); QObject *parent);
QmlProfilerEngine *q; QmlProfilerEngine *q;
@@ -80,6 +80,7 @@ public:
AbstractQmlProfilerRunner *m_runner; AbstractQmlProfilerRunner *m_runner;
QTimer m_noDebugOutputTimer; QTimer m_noDebugOutputTimer;
QmlDebug::QmlOutputParser m_outputParser; QmlDebug::QmlOutputParser m_outputParser;
const AnalyzerStartParameters sp;
}; };
AbstractQmlProfilerRunner * AbstractQmlProfilerRunner *
@@ -121,10 +122,7 @@ QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(ProjectExplorer::RunCo
const ProjectExplorer::IDevice::ConstPtr device = const ProjectExplorer::IDevice::ConstPtr device =
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit()); ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0); QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
QTcpServer server; conf.port = sp.analyzerPort;
if (!server.listen(QHostAddress::LocalHost) || !server.listen(QHostAddress::LocalHostIPv6))
return 0;
conf.port = server.serverPort();
runner = new LocalQmlProfilerRunner(conf, parent); runner = new LocalQmlProfilerRunner(conf, parent);
} }
return runner; return runner;
@@ -138,7 +136,7 @@ QmlProfilerEngine::QmlProfilerEngine(IAnalyzerTool *tool,
const Analyzer::AnalyzerStartParameters &sp, const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) ProjectExplorer::RunConfiguration *runConfiguration)
: IAnalyzerEngine(tool, sp, runConfiguration) : IAnalyzerEngine(tool, sp, runConfiguration)
, d(new QmlProfilerEnginePrivate(this)) , d(new QmlProfilerEnginePrivate(this, sp))
{ {
d->m_profilerState = 0; d->m_profilerState = 0;
@@ -185,7 +183,7 @@ bool QmlProfilerEngine::start()
} }
} }
d->m_runner = QmlProfilerEnginePrivate::createRunner(runConfiguration(), this); d->m_runner = d->createRunner(runConfiguration(), this);
if (LocalQmlProfilerRunner *qmlRunner = qobject_cast<LocalQmlProfilerRunner *>(d->m_runner)) { if (LocalQmlProfilerRunner *qmlRunner = qobject_cast<LocalQmlProfilerRunner *>(d->m_runner)) {
if (!qmlRunner->hasExecutable()) { if (!qmlRunner->hasExecutable()) {
@@ -203,7 +201,7 @@ bool QmlProfilerEngine::start()
d->m_runner->start(); d->m_runner->start();
d->m_noDebugOutputTimer.start(); d->m_noDebugOutputTimer.start();
} else { } else {
emit processRunning(startParameters().connParams.port); emit processRunning(startParameters().analyzerPort);
} }
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning); d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning);

View File

@@ -257,7 +257,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
// FIXME: Check that there's something sensible in sp.connParams // FIXME: Check that there's something sensible in sp.connParams
if (isTcpConnection) if (isTcpConnection)
d->m_profilerConnections->setTcpConnection(sp.connParams.host, sp.connParams.port); d->m_profilerConnections->setTcpConnection(sp.analyzerHost, sp.analyzerPort);
d->m_runConfiguration = runConfiguration; d->m_runConfiguration = runConfiguration;
@@ -334,6 +334,8 @@ AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration
sp.analyzerCmdPrefix = rc3->commandPrefix(); sp.analyzerCmdPrefix = rc3->commandPrefix();
sp.displayName = rc3->displayName(); sp.displayName = rc3->displayName();
sp.sysroot = sysroot(rc3); sp.sysroot = sysroot(rc3);
sp.analyzerHost = sp.connParams.host;
sp.analyzerPort = sp.connParams.port;
} else { } else {
// What could that be? // What could that be?
QTC_ASSERT(false, return sp); QTC_ASSERT(false, return sp);
@@ -342,10 +344,12 @@ AnalyzerStartParameters QmlProfilerTool::createStartParameters(RunConfiguration
ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit()); ProjectExplorer::DeviceKitInformation::device(runConfiguration->target()->kit());
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
QTcpServer server; QTcpServer server;
if (!server.listen(QHostAddress::LocalHost) || !server.listen(QHostAddress::LocalHostIPv6)) if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) {
qWarning() << "Cannot open port on host for QML profiling.";
return sp; return sp;
sp.connParams.host = server.serverAddress().toString(); }
sp.connParams.port = server.serverPort(); sp.analyzerHost = server.serverAddress().toString();
sp.analyzerPort = server.serverPort();
} }
sp.startMode = StartQml; sp.startMode = StartQml;
return sp; return sp;
@@ -550,6 +554,8 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
sp.connParams.host = host; sp.connParams.host = host;
sp.connParams.port = port; sp.connParams.port = port;
sp.sysroot = sysroot; sp.sysroot = sysroot;
sp.analyzerHost = host;
sp.analyzerPort = port;
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0); AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt())); QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));