forked from qt-creator/qt-creator
Analyzer: refactor global and project tool settings usage.
IAnalyzerTool has now 2 new virtual methods used to create the global and per-project settings. No need to create any static factory method and pass a pointer to them to the AnalyzerGlobalSettings instance anymore. The Valgrind plugin is now using it, the memchecktool creates the settings for all valgrind tools. Change-Id: I3c5845ceb7151130032cfff4ab5b7b36ca2459d9 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
committed by
hjk
parent
4a8432112a
commit
9b19a9c8e2
@@ -41,6 +41,7 @@
|
|||||||
#include "analyzerstartparameters.h"
|
#include "analyzerstartparameters.h"
|
||||||
#include "analyzerutils.h"
|
#include "analyzerutils.h"
|
||||||
#include "ianalyzertool.h"
|
#include "ianalyzertool.h"
|
||||||
|
#include "analyzersettings.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/findplaceholder.h>
|
#include <coreplugin/findplaceholder.h>
|
||||||
@@ -809,6 +810,7 @@ void AnalyzerManager::shutdown()
|
|||||||
void AnalyzerManager::addTool(IAnalyzerTool *tool, const StartModes &modes)
|
void AnalyzerManager::addTool(IAnalyzerTool *tool, const StartModes &modes)
|
||||||
{
|
{
|
||||||
m_instance->d->addTool(tool, modes);
|
m_instance->d->addTool(tool, modes);
|
||||||
|
AnalyzerGlobalSettings::instance()->registerTool(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool, const QString &title,
|
QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool, const QString &title,
|
||||||
@@ -829,6 +831,11 @@ IAnalyzerTool *AnalyzerManager::currentSelectedTool()
|
|||||||
return m_instance->d->m_currentTool;
|
return m_instance->d->m_currentTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<IAnalyzerTool *> AnalyzerManager::tools()
|
||||||
|
{
|
||||||
|
return m_instance->d->m_tools;
|
||||||
|
}
|
||||||
|
|
||||||
void AnalyzerManager::selectTool(IAnalyzerTool *tool, StartMode mode)
|
void AnalyzerManager::selectTool(IAnalyzerTool *tool, StartMode mode)
|
||||||
{
|
{
|
||||||
m_instance->d->selectTool(tool, mode);
|
m_instance->d->selectTool(tool, mode);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public:
|
|||||||
|
|
||||||
static void showMode();
|
static void showMode();
|
||||||
static IAnalyzerTool *currentSelectedTool();
|
static IAnalyzerTool *currentSelectedTool();
|
||||||
|
static QList<IAnalyzerTool *> tools();
|
||||||
static void selectTool(IAnalyzerTool *tool, StartMode mode);
|
static void selectTool(IAnalyzerTool *tool, StartMode mode);
|
||||||
static void startTool(IAnalyzerTool *tool, StartMode mode);
|
static void startTool(IAnalyzerTool *tool, StartMode mode);
|
||||||
static void stopTool();
|
static void stopTool();
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ QVariantMap AnalyzerSettings::toMap(const QList<AbstractAnalyzerSubConfig *> &su
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AnalyzerGlobalSettings::AnalyzerGlobalSettings(QObject *parent)
|
AnalyzerGlobalSettings::AnalyzerGlobalSettings(QObject *parent)
|
||||||
: AnalyzerSettings(parent)
|
: AnalyzerSettings(parent)
|
||||||
{
|
{
|
||||||
@@ -143,30 +144,26 @@ void AnalyzerGlobalSettings::writeSettings() const
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalyzerGlobalSettings::registerSubConfigs
|
void AnalyzerGlobalSettings::registerTool(IAnalyzerTool *tool)
|
||||||
(AnalyzerSubConfigFactory globalCreator, AnalyzerSubConfigFactory projectCreator)
|
|
||||||
{
|
{
|
||||||
m_projectSubConfigFactories.append(projectCreator);
|
AbstractAnalyzerSubConfig *config = tool->createGlobalSettings();
|
||||||
|
if (config) {
|
||||||
AbstractAnalyzerSubConfig *config = globalCreator();
|
m_subConfigs.append(config);
|
||||||
m_subConfigs.append(config);
|
AnalyzerPlugin::instance()->addAutoReleasedObject(new AnalyzerOptionsPage(config));
|
||||||
AnalyzerPlugin::instance()->addAutoReleasedObject(new AnalyzerOptionsPage(config));
|
readSettings();
|
||||||
|
}
|
||||||
readSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<AnalyzerSubConfigFactory> AnalyzerGlobalSettings::projectSubConfigFactories() const
|
|
||||||
{
|
|
||||||
return m_projectSubConfigFactories;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnalyzerProjectSettings::AnalyzerProjectSettings(QObject *parent)
|
AnalyzerProjectSettings::AnalyzerProjectSettings(QObject *parent)
|
||||||
: AnalyzerSettings(parent), m_useGlobalSettings(true)
|
: AnalyzerSettings(parent), m_useGlobalSettings(true)
|
||||||
{
|
{
|
||||||
|
QList<IAnalyzerTool*> tools = AnalyzerManager::tools();
|
||||||
// add sub configs
|
// add sub configs
|
||||||
foreach (AnalyzerSubConfigFactory factory, AnalyzerGlobalSettings::instance()->projectSubConfigFactories()) {
|
foreach (IAnalyzerTool *tool, tools) {
|
||||||
AbstractAnalyzerSubConfig *config = factory();
|
AbstractAnalyzerSubConfig *config = tool->createProjectSettings();
|
||||||
m_customConfigurations.append(config);
|
if (config)
|
||||||
|
m_customConfigurations.append(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_subConfigs = AnalyzerGlobalSettings::instance()->subConfigs();
|
m_subConfigs = AnalyzerGlobalSettings::instance()->subConfigs();
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
|
|
||||||
namespace Analyzer {
|
namespace Analyzer {
|
||||||
|
|
||||||
|
class IAnalyzerTool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to set @p val if @p key is present in @p map.
|
* Utility function to set @p val if @p key is present in @p map.
|
||||||
*/
|
*/
|
||||||
@@ -121,8 +123,6 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef AbstractAnalyzerSubConfig *(*AnalyzerSubConfigFactory)();
|
|
||||||
|
|
||||||
// global and local settings are loaded and saved differently, and they also handle suppressions
|
// global and local settings are loaded and saved differently, and they also handle suppressions
|
||||||
// differently.
|
// differently.
|
||||||
/**
|
/**
|
||||||
@@ -144,13 +144,11 @@ public:
|
|||||||
void writeSettings() const;
|
void writeSettings() const;
|
||||||
void readSettings();
|
void readSettings();
|
||||||
|
|
||||||
void registerSubConfigs(AnalyzerSubConfigFactory globalFactory, AnalyzerSubConfigFactory projectFactory);
|
void registerTool(IAnalyzerTool *tool);
|
||||||
QList<AnalyzerSubConfigFactory> projectSubConfigFactories() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AnalyzerGlobalSettings(QObject *parent);
|
AnalyzerGlobalSettings(QObject *parent);
|
||||||
static AnalyzerGlobalSettings *m_instance;
|
static AnalyzerGlobalSettings *m_instance;
|
||||||
QList<AnalyzerSubConfigFactory> m_projectSubConfigFactories;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -70,4 +70,14 @@ QString IAnalyzerTool::defaultActionName(const IAnalyzerTool *tool, StartMode mo
|
|||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractAnalyzerSubConfig *IAnalyzerTool::createGlobalSettings()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractAnalyzerSubConfig *IAnalyzerTool::createProjectSettings()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Analyzer
|
} // namespace Analyzer
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace Analyzer {
|
|||||||
|
|
||||||
class IAnalyzerOutputPaneAdapter;
|
class IAnalyzerOutputPaneAdapter;
|
||||||
class IAnalyzerEngine;
|
class IAnalyzerEngine;
|
||||||
|
class AbstractAnalyzerSubConfig;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,6 +138,12 @@ public:
|
|||||||
|
|
||||||
/// Called when tools gets deselected.
|
/// Called when tools gets deselected.
|
||||||
virtual void toolDeselected() const {}
|
virtual void toolDeselected() const {}
|
||||||
|
|
||||||
|
/// Factory method to create the global tool setting
|
||||||
|
virtual AbstractAnalyzerSubConfig *createGlobalSettings();
|
||||||
|
|
||||||
|
/// Factory method to create the project tool setting
|
||||||
|
virtual AbstractAnalyzerSubConfig *createProjectSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Analyzer
|
} // namespace Analyzer
|
||||||
|
|||||||
@@ -298,7 +298,17 @@ QString MemcheckTool::displayName() const
|
|||||||
QString MemcheckTool::description() const
|
QString MemcheckTool::description() const
|
||||||
{
|
{
|
||||||
return tr("Valgrind Analyze Memory uses the \"memcheck\" tool to find "
|
return tr("Valgrind Analyze Memory uses the \"memcheck\" tool to find "
|
||||||
"memory leaks");
|
"memory leaks");
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractAnalyzerSubConfig *MemcheckTool::createGlobalSettings()
|
||||||
|
{
|
||||||
|
return new ValgrindGlobalSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractAnalyzerSubConfig *MemcheckTool::createProjectSettings()
|
||||||
|
{
|
||||||
|
return new ValgrindProjectSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
IAnalyzerTool::ToolMode MemcheckTool::toolMode() const
|
IAnalyzerTool::ToolMode MemcheckTool::toolMode() const
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ public:
|
|||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
|
|
||||||
|
// Create the valgrind settings (for all valgrind tools)
|
||||||
|
Analyzer::AbstractAnalyzerSubConfig *createGlobalSettings();
|
||||||
|
Analyzer::AbstractAnalyzerSubConfig *createProjectSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void settingsDestroyed(QObject *settings);
|
void settingsDestroyed(QObject *settings);
|
||||||
void maybeActiveRunConfigurationChanged();
|
void maybeActiveRunConfigurationChanged();
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
#include "callgrindtool.h"
|
#include "callgrindtool.h"
|
||||||
#include "memchecktool.h"
|
#include "memchecktool.h"
|
||||||
#include "valgrindsettings.h"
|
|
||||||
|
|
||||||
#include <analyzerbase/analyzerconstants.h>
|
#include <analyzerbase/analyzerconstants.h>
|
||||||
#include <analyzerbase/analyzermanager.h>
|
#include <analyzerbase/analyzermanager.h>
|
||||||
@@ -96,20 +95,8 @@ void ValgrindPlugin::startValgrindTool(IAnalyzerTool *tool, StartMode mode)
|
|||||||
startRemoteTool(tool);
|
startRemoteTool(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AbstractAnalyzerSubConfig *globalValgrindFactory()
|
|
||||||
{
|
|
||||||
return new ValgrindGlobalSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
static AbstractAnalyzerSubConfig *projectValgrindFactory()
|
|
||||||
{
|
|
||||||
return new ValgrindProjectSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||||
{
|
{
|
||||||
AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalValgrindFactory, &projectValgrindFactory);
|
|
||||||
|
|
||||||
StartModes modes;
|
StartModes modes;
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
modes.append(StartMode(StartLocal));
|
modes.append(StartMode(StartLocal));
|
||||||
|
|||||||
Reference in New Issue
Block a user