forked from qt-creator/qt-creator
QmlProfiler: Make creation of local RunControls more flexible
In order for plugins to create a RunControl for locally running applications that do not use LocalApplicationRunConfiguration it is required to export an API that takes care of the internal setup. Also this removes the hard dependency on LocalApplicationRunConfiguration. We don't want to expose Internal classes in public API, so we have to make QmlProfiler::Internal::QmlProfilerRunControl and QmlProfiler::Internal::QmlProfilerStateManager public. Also, AbstractQmlProfilerRunner doesn't do anything useful and can be removed. Change-Id: I0403e5b17e14ac894addd818ad7b249c51a8ed8d Reviewed-by: hjk <hjk@theqtcompany.com> Reviewed-by: Benjamin Zeller <benjamin.zeller@canonical.com> Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -33,9 +33,6 @@
|
||||
#include "qmlprofilerengine.h"
|
||||
|
||||
#include <analyzerbase/ianalyzertool.h>
|
||||
#include <analyzerbase/analyzermanager.h>
|
||||
#include <analyzerbase/analyzerstartparameters.h>
|
||||
#include <analyzerbase/analyzerruncontrol.h>
|
||||
|
||||
#include <debugger/debuggerrunconfigurationaspect.h>
|
||||
|
||||
@@ -49,8 +46,6 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QTcpServer>
|
||||
|
||||
using namespace Analyzer;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -84,16 +79,11 @@ static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration
|
||||
sp.debuggeeArgs = rc->commandLineArguments();
|
||||
sp.displayName = rc->displayName();
|
||||
|
||||
const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
|
||||
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
QTcpServer server;
|
||||
if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) {
|
||||
qWarning() << "Cannot open port on host for QML profiling.";
|
||||
return sp;
|
||||
}
|
||||
sp.analyzerHost = server.serverAddress().toString();
|
||||
sp.analyzerPort = server.serverPort();
|
||||
}
|
||||
quint16 localPort = LocalQmlProfilerRunner::findFreePort(sp.analyzerHost);
|
||||
if (localPort == 0)
|
||||
return sp;
|
||||
sp.analyzerPort = localPort;
|
||||
|
||||
sp.startMode = StartLocal;
|
||||
return sp;
|
||||
}
|
||||
@@ -104,27 +94,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
|
||||
|
||||
AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration);
|
||||
sp.runMode = mode;
|
||||
|
||||
// only desktop device is supported
|
||||
const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
|
||||
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
|
||||
|
||||
AnalyzerRunControl *rc = AnalyzerManager::createRunControl(sp, runConfiguration);
|
||||
QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc);
|
||||
if (!engine) {
|
||||
delete rc;
|
||||
return 0;
|
||||
}
|
||||
LocalQmlProfilerRunner *runner = LocalQmlProfilerRunner::createLocalRunner(runConfiguration, sp, errorMessage, engine);
|
||||
if (!runner)
|
||||
return 0;
|
||||
connect(runner, SIGNAL(stopped()), engine, SLOT(notifyRemoteFinished()));
|
||||
connect(runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
||||
engine, SLOT(logApplicationMessage(QString,Utils::OutputFormat)));
|
||||
connect(engine, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), runner,
|
||||
SLOT(start()));
|
||||
connect(rc, SIGNAL(finished()), runner, SLOT(stop()));
|
||||
return rc;
|
||||
return LocalQmlProfilerRunner::createLocalRunControl(runConfiguration, sp, errorMessage);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user