Commit 213cb601 authored by hjk's avatar hjk

Analyzer: Use AnalyzerManager for run control creation

Less code.

Change-Id: Ic26d291ada7efd05899623738d89c52b4175716c
Reviewed-by: default avatarAurindam Jana <aurindam.jana@digia.com>
parent c1919f0a
...@@ -867,11 +867,17 @@ void AnalyzerManager::handleToolFinished() ...@@ -867,11 +867,17 @@ void AnalyzerManager::handleToolFinished()
m_instance->d->handleToolFinished(); m_instance->d->handleToolFinished();
} }
IAnalyzerTool *AnalyzerManager::toolFromRunMode(RunMode runMode) AnalyzerRunControl *AnalyzerManager::createRunControl(
const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode runMode,
QString *errorMessage)
{ {
foreach (IAnalyzerTool *tool, m_instance->d->m_tools) foreach (IAnalyzerTool *tool, m_instance->d->m_tools)
if (tool->runMode() == runMode) if (tool->runMode() == runMode)
return tool; return tool->createRunControl(sp, runConfiguration);
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0; return 0;
} }
......
...@@ -43,16 +43,17 @@ class QDockWidget; ...@@ -43,16 +43,17 @@ class QDockWidget;
class QAction; class QAction;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { namespace Utils { class FancyMainWindow; }
class FancyMainWindow; namespace ProjectExplorer { class RunConfiguration; }
}
namespace Analyzer { namespace Analyzer {
typedef QList<StartMode> StartModes; typedef QList<StartMode> StartModes;
class IAnalyzerTool; class IAnalyzerTool;
class AnalyzerRunControl;
class AnalyzerManagerPrivate; class AnalyzerManagerPrivate;
class AnalyzerStartParameters;
// FIXME: Merge with AnalyzerPlugin. // FIXME: Merge with AnalyzerPlugin.
...@@ -69,7 +70,6 @@ public: ...@@ -69,7 +70,6 @@ public:
// Register a tool and initialize it. // Register a tool and initialize it.
static void addTool(IAnalyzerTool *tool, const StartModes &mode); static void addTool(IAnalyzerTool *tool, const StartModes &mode);
static IAnalyzerTool *toolFromRunMode(ProjectExplorer::RunMode runMode);
// Dockwidgets are registered to the main window. // Dockwidgets are registered to the main window.
static QDockWidget *createDockWidget(IAnalyzerTool *tool, const QString &title, static QDockWidget *createDockWidget(IAnalyzerTool *tool, const QString &title,
...@@ -97,6 +97,10 @@ public: ...@@ -97,6 +97,10 @@ public:
static void handleToolFinished(); static void handleToolFinished();
static QAction *stopAction(); static QAction *stopAction();
static AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode runMode,
QString *errorMessage);
private: private:
friend class AnalyzerManagerPrivate; friend class AnalyzerManagerPrivate;
AnalyzerManagerPrivate *const d; AnalyzerManagerPrivate *const d;
......
...@@ -53,16 +53,9 @@ namespace Internal { ...@@ -53,16 +53,9 @@ namespace Internal {
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig, RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
RunMode runMode, QString *errorMessage) RunMode runMode, QString *errorMessage)
{ {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(runMode); Target *target = runConfig->target();
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0;
}
AnalyzerStartParameters params; AnalyzerStartParameters params;
params.runMode = runMode; params.runMode = runMode;
Target *target = runConfig->target();
params.displayName = AndroidManager::packageName(target); params.displayName = AndroidManager::packageName(target);
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString(); params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
// TODO: Not sure if these are the right paths. // TODO: Not sure if these are the right paths.
...@@ -75,7 +68,8 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati ...@@ -75,7 +68,8 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
params.startMode = StartQmlRemote; params.startMode = StartQmlRemote;
} }
AnalyzerRunControl *analyzerRunControl = tool->createRunControl(params, runConfig); AnalyzerRunControl *analyzerRunControl =
AnalyzerManager::createRunControl(params, runConfig, runMode, errorMessage);
(void) new AndroidAnalyzeSupport(runConfig, analyzerRunControl); (void) new AndroidAnalyzeSupport(runConfig, analyzerRunControl);
return analyzerRunControl; return analyzerRunControl;
} }
......
...@@ -48,8 +48,7 @@ class AndroidAnalyzeSupport : public AndroidRunSupport ...@@ -48,8 +48,7 @@ class AndroidAnalyzeSupport : public AndroidRunSupport
public: public:
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig, static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode, ProjectExplorer::RunMode runMode, QString *errorMessage);
QString *errorMessage);
AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig, AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
Analyzer::AnalyzerRunControl *runControl); Analyzer::AnalyzerRunControl *runControl);
......
...@@ -117,13 +117,6 @@ static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration ...@@ -117,13 +117,6 @@ static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{ {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected"); // never happens
return 0;
}
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration); AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration);
...@@ -133,7 +126,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat ...@@ -133,7 +126,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit()); const IDevice::ConstPtr device = 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);
AnalyzerRunControl *rc = tool->createRunControl(sp, runConfiguration); AnalyzerRunControl *rc = AnalyzerManager::createRunControl(sp, runConfiguration, mode, errorMessage);
QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc); QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc);
if (!engine) { if (!engine) {
delete rc; delete rc;
......
...@@ -189,15 +189,8 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo ...@@ -189,15 +189,8 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo
return runControl; return runControl;
} }
case QmlProfilerRunMode: { case QmlProfilerRunMode: {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0;
}
const AnalyzerStartParameters params = createAnalyzerStartParameters(rc, mode); const AnalyzerStartParameters params = createAnalyzerStartParameters(rc, mode);
AnalyzerRunControl *runControl = tool->createRunControl(params, runConfig); AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig, mode, errorMessage);
//AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig);
QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl); QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl);
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished())); connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
return runControl; return runControl;
......
...@@ -107,18 +107,8 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru ...@@ -107,18 +107,8 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru
return runControl; return runControl;
} }
case QmlProfilerRunMode: { case QmlProfilerRunMode: {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected.");
return 0;
}
AnalyzerStartParameters params = RemoteLinuxAnalyzeSupport::startParameters(rc, mode); AnalyzerStartParameters params = RemoteLinuxAnalyzeSupport::startParameters(rc, mode);
//AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig); AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig, mode, errorMessage);
AnalyzerRunControl *runControl = tool->createRunControl(params, runConfig);
//m_engine->setRunControl(this);
RemoteLinuxAnalyzeSupport * const analyzeSupport = RemoteLinuxAnalyzeSupport * const analyzeSupport =
new RemoteLinuxAnalyzeSupport(rc, runControl, mode); new RemoteLinuxAnalyzeSupport(rc, runControl, mode);
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished())); connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
......
...@@ -106,17 +106,8 @@ static AnalyzerStartParameters createValgrindStartParameters(RunConfiguration *r ...@@ -106,17 +106,8 @@ static AnalyzerStartParameters createValgrindStartParameters(RunConfiguration *r
RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
{ {
IAnalyzerTool *tool = AnalyzerManager::toolFromRunMode(mode);
if (!tool) {
if (errorMessage)
*errorMessage = tr("No analyzer tool selected"); // never happens
return 0;
}
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = createValgrindStartParameters(runConfiguration); AnalyzerStartParameters sp = createValgrindStartParameters(runConfiguration);
return tool->createRunControl(sp, runConfiguration); return AnalyzerManager::createRunControl(sp, runConfiguration, mode, errorMessage);
} }
IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc) IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment