forked from qt-creator/qt-creator
Analyzer: Slim down AnalyzerStartParameters
* SysRoot can always be determined from kit. * Pass around RunMode as extra parameter not as part of AnalyzerStartParameters. That's closer to the pattern used elsewhere. * Environment was always initialized from the runconfig's EnvironmentAspect. The tools can do that directly. * Provide setter for display name for cases where it is not equal to RunConfiguration::displayName Change-Id: I811a0d7cdeb55cc37a16a593b3942abb567a2150 Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
This commit is contained in:
@@ -60,7 +60,7 @@ Analyzer::AnalyzerRunControl *LocalQmlProfilerRunner::createLocalRunControl(
|
||||
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
|
||||
|
||||
Analyzer::AnalyzerRunControl *rc = Analyzer::AnalyzerManager::createRunControl(
|
||||
sp, runConfiguration);
|
||||
sp, runConfiguration, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc);
|
||||
if (!engine) {
|
||||
delete rc;
|
||||
@@ -70,9 +70,10 @@ Analyzer::AnalyzerRunControl *LocalQmlProfilerRunner::createLocalRunControl(
|
||||
Configuration conf;
|
||||
conf.executable = sp.debuggee;
|
||||
conf.executableArguments = sp.debuggeeArgs;
|
||||
conf.workingDirectory = sp.workingDirectory;
|
||||
conf.environment = sp.environment;
|
||||
conf.workingDirectory = rc->workingDirectory();
|
||||
conf.socket = sp.analyzerSocket;
|
||||
if (EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>())
|
||||
conf.environment = environment->environment();
|
||||
conf.port = sp.analyzerPort;
|
||||
|
||||
if (conf.executable.isEmpty()) {
|
||||
|
||||
@@ -60,7 +60,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
auto tool = new QmlProfilerTool(this);
|
||||
auto widgetCreator = [tool] { return tool->createWidgets(); };
|
||||
auto runControlCreator = [tool](const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) {
|
||||
ProjectExplorer::RunConfiguration *runConfiguration, Core::Id) {
|
||||
return tool->createRunControl(sp, runConfiguration);
|
||||
};
|
||||
|
||||
|
||||
@@ -66,12 +66,10 @@ namespace QmlProfiler {
|
||||
class QmlProfilerRunControl::QmlProfilerRunControlPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerRunControlPrivate() : m_running(false) {}
|
||||
|
||||
QmlProfilerStateManager *m_profilerState;
|
||||
QmlProfilerStateManager *m_profilerState = 0;
|
||||
QTimer m_noDebugOutputTimer;
|
||||
QmlDebug::QmlOutputParser m_outputParser;
|
||||
bool m_running;
|
||||
bool m_running = false;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -79,11 +77,10 @@ public:
|
||||
//
|
||||
|
||||
QmlProfilerRunControl::QmlProfilerRunControl(const AnalyzerStartParameters &sp,
|
||||
RunConfiguration *runConfiguration) :
|
||||
AnalyzerRunControl(sp, runConfiguration), d(new QmlProfilerRunControlPrivate)
|
||||
RunConfiguration *runConfiguration)
|
||||
: AnalyzerRunControl(sp, runConfiguration, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
|
||||
, d(new QmlProfilerRunControlPrivate)
|
||||
{
|
||||
d->m_profilerState = 0;
|
||||
|
||||
// Only wait 4 seconds for the 'Waiting for connection' on application output, then just try to connect
|
||||
// (application output might be redirected / blocked)
|
||||
d->m_noDebugOutputTimer.setSingleShot(true);
|
||||
|
||||
@@ -69,18 +69,12 @@ bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, Co
|
||||
static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration *runConfiguration)
|
||||
{
|
||||
AnalyzerStartParameters sp;
|
||||
EnvironmentAspect *environment = runConfiguration->extraAspect<EnvironmentAspect>();
|
||||
|
||||
// FIXME: This is only used to communicate the connParams settings.
|
||||
LocalApplicationRunConfiguration *rc =
|
||||
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
|
||||
auto rc = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
|
||||
QTC_ASSERT(rc, return sp);
|
||||
if (environment)
|
||||
sp.environment = environment->environment();
|
||||
sp.workingDirectory = rc->workingDirectory();
|
||||
sp.debuggee = rc->executable();
|
||||
sp.debuggeeArgs = rc->commandLineArguments();
|
||||
sp.displayName = rc->displayName();
|
||||
|
||||
const QtSupport::BaseQtVersion *version =
|
||||
QtSupport::QtKitInformation::qtVersion(runConfiguration->target()->kit());
|
||||
@@ -103,7 +97,6 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
|
||||
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
|
||||
|
||||
AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration);
|
||||
sp.runMode = mode;
|
||||
return LocalQmlProfilerRunner::createLocalRunControl(runConfiguration, sp, errorMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,6 +197,15 @@ QmlProfilerTool::~QmlProfilerTool()
|
||||
delete d;
|
||||
}
|
||||
|
||||
static QString sysroot(RunConfiguration *runConfig)
|
||||
{
|
||||
QTC_ASSERT(runConfig, return QString());
|
||||
Kit *k = runConfig->target()->kit();
|
||||
if (k && SysRootKitInformation::hasSysRoot(k))
|
||||
return SysRootKitInformation::sysRoot(runConfig->target()->kit()).toString();
|
||||
return QString();
|
||||
}
|
||||
|
||||
AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParameters &sp,
|
||||
RunConfiguration *runConfiguration)
|
||||
{
|
||||
@@ -231,7 +240,7 @@ AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParamet
|
||||
projectDirectory = project->projectDirectory().toString();
|
||||
}
|
||||
|
||||
populateFileFinder(projectDirectory, sp.sysroot);
|
||||
populateFileFinder(projectDirectory, sysroot(runConfiguration));
|
||||
|
||||
if (sp.analyzerSocket.isEmpty())
|
||||
connect(engine, &QmlProfilerRunControl::processRunning,
|
||||
@@ -242,15 +251,6 @@ AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParamet
|
||||
return engine;
|
||||
}
|
||||
|
||||
static QString sysroot(RunConfiguration *runConfig)
|
||||
{
|
||||
QTC_ASSERT(runConfig, return QString());
|
||||
Kit *k = runConfig->target()->kit();
|
||||
if (k && SysRootKitInformation::hasSysRoot(k))
|
||||
return SysRootKitInformation::sysRoot(runConfig->target()->kit()).toString();
|
||||
return QString();
|
||||
}
|
||||
|
||||
QWidget *QmlProfilerTool::createWidgets()
|
||||
{
|
||||
QTC_ASSERT(!d->m_viewContainer, return 0);
|
||||
@@ -526,7 +526,6 @@ void QmlProfilerTool::startRemoteTool()
|
||||
sp.connParams = device->sshParameters();
|
||||
sp.analyzerHost = device->qmlProfilerHost();
|
||||
}
|
||||
sp.sysroot = SysRootKitInformation::sysRoot(kit).toString();
|
||||
sp.analyzerPort = port;
|
||||
|
||||
AnalyzerRunControl *rc = createRunControl(sp, 0);
|
||||
|
||||
Reference in New Issue
Block a user