forked from qt-creator/qt-creator
QmlProfiler: Inline LocalQmlProfilerSupport
Task-number: QTCREATORBUG-29168 Change-Id: I991529d42bbe5b75b3a0bc13baf7c64005d9e1bb Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -142,45 +142,20 @@ void QmlProfilerRunner::profilerStateChanged()
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// LocalQmlProfilerSupport
|
||||
//
|
||||
|
||||
static QUrl localServerUrl(RunControl *runControl)
|
||||
RunWorker *createLocalQmlProfilerWorker(RunControl *runControl)
|
||||
{
|
||||
QUrl serverUrl;
|
||||
Kit *kit = runControl->kit();
|
||||
const QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit);
|
||||
if (version) {
|
||||
if (version->qtVersion() >= QVersionNumber(5, 6, 0))
|
||||
serverUrl = Utils::urlFromLocalSocket();
|
||||
else
|
||||
serverUrl = Utils::urlFromLocalHostAndFreePort();
|
||||
} else {
|
||||
qWarning("Running QML profiler on Kit without Qt version?");
|
||||
serverUrl = Utils::urlFromLocalHostAndFreePort();
|
||||
}
|
||||
return serverUrl;
|
||||
}
|
||||
auto worker = new SimpleTargetRunner(runControl);
|
||||
|
||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl)
|
||||
: LocalQmlProfilerSupport(runControl, localServerUrl(runControl))
|
||||
{
|
||||
}
|
||||
|
||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const QUrl &serverUrl)
|
||||
: SimpleTargetRunner(runControl)
|
||||
{
|
||||
setId("LocalQmlProfilerSupport");
|
||||
worker->setId("LocalQmlProfilerSupport");
|
||||
|
||||
auto profiler = new QmlProfilerRunner(runControl);
|
||||
|
||||
addStopDependency(profiler);
|
||||
worker->addStopDependency(profiler);
|
||||
// We need to open the local server before the application tries to connect.
|
||||
// In the TCP case, it doesn't hurt either to start the profiler before.
|
||||
addStartDependency(profiler);
|
||||
worker->addStartDependency(profiler);
|
||||
|
||||
setStartModifier([this, runControl, serverUrl] {
|
||||
worker->setStartModifier([worker, runControl] {
|
||||
|
||||
QUrl serverUrl = runControl->qmlChannel();
|
||||
QString code;
|
||||
@@ -194,14 +169,15 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q
|
||||
QString arguments = Utils::ProcessArgs::quoteArg(
|
||||
qmlDebugCommandLineArguments(QmlProfilerServices, code, true));
|
||||
|
||||
Utils::CommandLine cmd = commandLine();
|
||||
Utils::CommandLine cmd = worker->commandLine();
|
||||
const QString oldArgs = cmd.arguments();
|
||||
cmd.setArguments(arguments);
|
||||
cmd.addArgs(oldArgs, Utils::CommandLine::Raw);
|
||||
setCommandLine(cmd);
|
||||
|
||||
forceRunOnHost();
|
||||
worker->setCommandLine(cmd);
|
||||
worker->forceRunOnHost();
|
||||
});
|
||||
|
||||
return worker;
|
||||
}
|
||||
|
||||
// Factories
|
||||
@@ -224,7 +200,7 @@ public:
|
||||
LocalQmlProfilerRunWorkerFactory()
|
||||
{
|
||||
setId(ProjectExplorer::Constants::QML_PROFILER_RUN_FACTORY);
|
||||
setProduct<LocalQmlProfilerSupport>();
|
||||
setProducer(&createLocalQmlProfilerWorker);
|
||||
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
|
||||
@@ -238,5 +214,4 @@ void setupQmlProfilerRunning()
|
||||
static LocalQmlProfilerRunWorkerFactory theLocalQmlProfilerRunWorkerFactory;
|
||||
}
|
||||
|
||||
|
||||
} // QmlProfiler::Internal
|
||||
|
@@ -37,16 +37,7 @@ private:
|
||||
QmlProfilerRunnerPrivate *d;
|
||||
};
|
||||
|
||||
class LocalQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
|
||||
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl,
|
||||
const QUrl &serverUrl);
|
||||
};
|
||||
|
||||
ProjectExplorer::RunWorker *createLocalQmlProfilerWorker(ProjectExplorer::RunControl *runControl);
|
||||
void setupQmlProfilerRunning();
|
||||
|
||||
} // QmlProfiler::Internal
|
||||
|
@@ -29,8 +29,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
|
||||
void LocalQmlProfilerRunnerTest::testRunner()
|
||||
{
|
||||
QPointer<RunControl> runControl;
|
||||
QPointer<LocalQmlProfilerSupport> profiler;
|
||||
QUrl serverUrl;
|
||||
QPointer<RunWorker> profiler;
|
||||
|
||||
bool running = false;
|
||||
bool started = false;
|
||||
@@ -38,14 +37,10 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
int runCount = 0;
|
||||
int stopCount = 0;
|
||||
|
||||
// should not be used anywhere but cannot be empty
|
||||
serverUrl.setScheme(Utils::urlSocketScheme());
|
||||
serverUrl.setPath("invalid");
|
||||
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setCommandLine(CommandLine{"\\-/|\\-/"});
|
||||
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
profiler = createLocalQmlProfilerWorker(runControl);
|
||||
|
||||
auto connectRunner = [&]() {
|
||||
connect(runControl, &RunControl::aboutToStart, this, [&] {
|
||||
@@ -85,13 +80,12 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
QTRY_VERIFY(runControl.isNull());
|
||||
QVERIFY(profiler.isNull());
|
||||
|
||||
serverUrl = Utils::urlFromLocalSocket();
|
||||
// comma is used to specify a test function. In this case, an invalid one.
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
|
||||
const FilePath app = FilePath::fromString(QCoreApplication::applicationFilePath());
|
||||
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
profiler = createLocalQmlProfilerWorker(runControl);
|
||||
connectRunner();
|
||||
runControl->initiateStart();
|
||||
|
||||
@@ -106,11 +100,9 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
QTRY_VERIFY(runControl.isNull());
|
||||
QVERIFY(profiler.isNull());
|
||||
|
||||
serverUrl.clear();
|
||||
serverUrl = Utils::urlFromLocalHostAndFreePort();
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setCommandLine(CommandLine{app});
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
profiler = createLocalQmlProfilerWorker(runControl);
|
||||
connectRunner();
|
||||
runControl->initiateStart();
|
||||
|
||||
@@ -126,16 +118,9 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
QTRY_VERIFY(runControl.isNull());
|
||||
QVERIFY(profiler.isNull());
|
||||
|
||||
serverUrl.setScheme(Utils::urlSocketScheme());
|
||||
{
|
||||
Utils::TemporaryFile file("file with spaces");
|
||||
if (file.open())
|
||||
serverUrl.setPath(file.fileName());
|
||||
}
|
||||
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
profiler = createLocalQmlProfilerWorker(runControl);
|
||||
connectRunner();
|
||||
runControl->initiateStart();
|
||||
|
||||
|
Reference in New Issue
Block a user