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()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
RunWorker *createLocalQmlProfilerWorker(RunControl *runControl)
|
||||||
// LocalQmlProfilerSupport
|
|
||||||
//
|
|
||||||
|
|
||||||
static QUrl localServerUrl(RunControl *runControl)
|
|
||||||
{
|
{
|
||||||
QUrl serverUrl;
|
auto worker = new SimpleTargetRunner(runControl);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl)
|
worker->setId("LocalQmlProfilerSupport");
|
||||||
: LocalQmlProfilerSupport(runControl, localServerUrl(runControl))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const QUrl &serverUrl)
|
|
||||||
: SimpleTargetRunner(runControl)
|
|
||||||
{
|
|
||||||
setId("LocalQmlProfilerSupport");
|
|
||||||
|
|
||||||
auto profiler = new QmlProfilerRunner(runControl);
|
auto profiler = new QmlProfilerRunner(runControl);
|
||||||
|
|
||||||
addStopDependency(profiler);
|
worker->addStopDependency(profiler);
|
||||||
// We need to open the local server before the application tries to connect.
|
// 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.
|
// 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();
|
QUrl serverUrl = runControl->qmlChannel();
|
||||||
QString code;
|
QString code;
|
||||||
@@ -192,16 +167,17 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q
|
|||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
|
|
||||||
QString arguments = Utils::ProcessArgs::quoteArg(
|
QString arguments = Utils::ProcessArgs::quoteArg(
|
||||||
qmlDebugCommandLineArguments(QmlProfilerServices, code, true));
|
qmlDebugCommandLineArguments(QmlProfilerServices, code, true));
|
||||||
|
|
||||||
Utils::CommandLine cmd = commandLine();
|
Utils::CommandLine cmd = worker->commandLine();
|
||||||
const QString oldArgs = cmd.arguments();
|
const QString oldArgs = cmd.arguments();
|
||||||
cmd.setArguments(arguments);
|
cmd.setArguments(arguments);
|
||||||
cmd.addArgs(oldArgs, Utils::CommandLine::Raw);
|
cmd.addArgs(oldArgs, Utils::CommandLine::Raw);
|
||||||
setCommandLine(cmd);
|
worker->setCommandLine(cmd);
|
||||||
|
worker->forceRunOnHost();
|
||||||
forceRunOnHost();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return worker;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Factories
|
// Factories
|
||||||
@@ -224,7 +200,7 @@ public:
|
|||||||
LocalQmlProfilerRunWorkerFactory()
|
LocalQmlProfilerRunWorkerFactory()
|
||||||
{
|
{
|
||||||
setId(ProjectExplorer::Constants::QML_PROFILER_RUN_FACTORY);
|
setId(ProjectExplorer::Constants::QML_PROFILER_RUN_FACTORY);
|
||||||
setProduct<LocalQmlProfilerSupport>();
|
setProducer(&createLocalQmlProfilerWorker);
|
||||||
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||||
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||||
|
|
||||||
@@ -238,5 +214,4 @@ void setupQmlProfilerRunning()
|
|||||||
static LocalQmlProfilerRunWorkerFactory theLocalQmlProfilerRunWorkerFactory;
|
static LocalQmlProfilerRunWorkerFactory theLocalQmlProfilerRunWorkerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // QmlProfiler::Internal
|
} // QmlProfiler::Internal
|
||||||
|
@@ -37,16 +37,7 @@ private:
|
|||||||
QmlProfilerRunnerPrivate *d;
|
QmlProfilerRunnerPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocalQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner
|
ProjectExplorer::RunWorker *createLocalQmlProfilerWorker(ProjectExplorer::RunControl *runControl);
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
|
|
||||||
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl,
|
|
||||||
const QUrl &serverUrl);
|
|
||||||
};
|
|
||||||
|
|
||||||
void setupQmlProfilerRunning();
|
void setupQmlProfilerRunning();
|
||||||
|
|
||||||
} // QmlProfiler::Internal
|
} // QmlProfiler::Internal
|
||||||
|
@@ -29,8 +29,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
|
|||||||
void LocalQmlProfilerRunnerTest::testRunner()
|
void LocalQmlProfilerRunnerTest::testRunner()
|
||||||
{
|
{
|
||||||
QPointer<RunControl> runControl;
|
QPointer<RunControl> runControl;
|
||||||
QPointer<LocalQmlProfilerSupport> profiler;
|
QPointer<RunWorker> profiler;
|
||||||
QUrl serverUrl;
|
|
||||||
|
|
||||||
bool running = false;
|
bool running = false;
|
||||||
bool started = false;
|
bool started = false;
|
||||||
@@ -38,14 +37,10 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
|||||||
int runCount = 0;
|
int runCount = 0;
|
||||||
int stopCount = 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 = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||||
runControl->setCommandLine(CommandLine{"\\-/|\\-/"});
|
runControl->setCommandLine(CommandLine{"\\-/|\\-/"});
|
||||||
|
|
||||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
profiler = createLocalQmlProfilerWorker(runControl);
|
||||||
|
|
||||||
auto connectRunner = [&]() {
|
auto connectRunner = [&]() {
|
||||||
connect(runControl, &RunControl::aboutToStart, this, [&] {
|
connect(runControl, &RunControl::aboutToStart, this, [&] {
|
||||||
@@ -85,13 +80,12 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
|||||||
QTRY_VERIFY(runControl.isNull());
|
QTRY_VERIFY(runControl.isNull());
|
||||||
QVERIFY(profiler.isNull());
|
QVERIFY(profiler.isNull());
|
||||||
|
|
||||||
serverUrl = Utils::urlFromLocalSocket();
|
|
||||||
// comma is used to specify a test function. In this case, an invalid one.
|
// comma is used to specify a test function. In this case, an invalid one.
|
||||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||||
|
|
||||||
const FilePath app = FilePath::fromString(QCoreApplication::applicationFilePath());
|
const FilePath app = FilePath::fromString(QCoreApplication::applicationFilePath());
|
||||||
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
||||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
profiler = createLocalQmlProfilerWorker(runControl);
|
||||||
connectRunner();
|
connectRunner();
|
||||||
runControl->initiateStart();
|
runControl->initiateStart();
|
||||||
|
|
||||||
@@ -106,11 +100,9 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
|||||||
QTRY_VERIFY(runControl.isNull());
|
QTRY_VERIFY(runControl.isNull());
|
||||||
QVERIFY(profiler.isNull());
|
QVERIFY(profiler.isNull());
|
||||||
|
|
||||||
serverUrl.clear();
|
|
||||||
serverUrl = Utils::urlFromLocalHostAndFreePort();
|
|
||||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||||
runControl->setCommandLine(CommandLine{app});
|
runControl->setCommandLine(CommandLine{app});
|
||||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
profiler = createLocalQmlProfilerWorker(runControl);
|
||||||
connectRunner();
|
connectRunner();
|
||||||
runControl->initiateStart();
|
runControl->initiateStart();
|
||||||
|
|
||||||
@@ -126,16 +118,9 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
|||||||
QTRY_VERIFY(runControl.isNull());
|
QTRY_VERIFY(runControl.isNull());
|
||||||
QVERIFY(profiler.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 = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||||
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
||||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
profiler = createLocalQmlProfilerWorker(runControl);
|
||||||
connectRunner();
|
connectRunner();
|
||||||
runControl->initiateStart();
|
runControl->initiateStart();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user