forked from qt-creator/qt-creator
Analyzer: Dissolve IAnalyzerTool
Change-Id: I1fd90cf00d6b9dff54b4555a14747282830a4b93 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -178,9 +178,9 @@ public:
|
||||
QComboBox *m_toolBox;
|
||||
QStackedWidget *m_controlsStackWidget;
|
||||
StatusLabel *m_statusLabel;
|
||||
typedef QMap<IAnalyzerTool *, FancyMainWindowSettings> MainWindowSettingsMap;
|
||||
QHash<IAnalyzerTool *, QList<QDockWidget *> > m_toolWidgets;
|
||||
QHash<IAnalyzerTool *, QWidget *> m_controlsWidgetFromTool;
|
||||
typedef QMap<Id, FancyMainWindowSettings> MainWindowSettingsMap;
|
||||
QHash<Id, QList<QDockWidget *> > m_toolWidgets;
|
||||
QHash<Id, QWidget *> m_controlsWidgetFromTool;
|
||||
MainWindowSettingsMap m_defaultSettings;
|
||||
|
||||
// list of dock widgets to prevent memory leak
|
||||
@@ -437,7 +437,7 @@ bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const
|
||||
void AnalyzerManagerPrivate::startTool()
|
||||
{
|
||||
QTC_ASSERT(m_currentAction, return);
|
||||
m_currentAction->tool()->startTool(m_currentAction->startMode());
|
||||
m_currentAction->toolStarter()(m_currentAction->startMode());
|
||||
}
|
||||
|
||||
void AnalyzerManagerPrivate::modeChanged(IMode *mode)
|
||||
@@ -461,7 +461,7 @@ void AnalyzerManagerPrivate::selectSavedTool()
|
||||
if (settings->contains(QLatin1String(LAST_ACTIVE_TOOL))) {
|
||||
const Id lastAction = Id::fromSetting(settings->value(QLatin1String(LAST_ACTIVE_TOOL)));
|
||||
foreach (AnalyzerAction *action, m_actions) {
|
||||
if (action->id() == lastAction) {
|
||||
if (action->toolId() == lastAction) {
|
||||
selectAction(action);
|
||||
return;
|
||||
}
|
||||
@@ -497,29 +497,29 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
|
||||
// Clean up old tool.
|
||||
if (m_currentAction) {
|
||||
saveToolSettings(m_currentAction);
|
||||
foreach (QDockWidget *widget, m_toolWidgets.value(m_currentAction->tool()))
|
||||
foreach (QDockWidget *widget, m_toolWidgets.value(m_currentAction->toolId()))
|
||||
deactivateDock(widget);
|
||||
}
|
||||
|
||||
// Now change the tool.
|
||||
m_currentAction = action;
|
||||
|
||||
IAnalyzerTool *tool = action->tool();
|
||||
if (!m_defaultSettings.contains(tool)) {
|
||||
QWidget *widget = tool->createWidgets();
|
||||
Id toolId = action->toolId();
|
||||
if (!m_defaultSettings.contains(toolId)) {
|
||||
QWidget *widget = action->createWidget();
|
||||
QTC_CHECK(widget);
|
||||
m_defaultSettings.insert(tool, m_mainWindow->saveSettings());
|
||||
QTC_CHECK(!m_controlsWidgetFromTool.contains(tool));
|
||||
m_controlsWidgetFromTool[tool] = widget;
|
||||
m_defaultSettings.insert(toolId, m_mainWindow->saveSettings());
|
||||
QTC_CHECK(!m_controlsWidgetFromTool.contains(toolId));
|
||||
m_controlsWidgetFromTool[toolId] = widget;
|
||||
m_controlsStackWidget->addWidget(widget);
|
||||
}
|
||||
foreach (QDockWidget *widget, m_toolWidgets.value(tool))
|
||||
foreach (QDockWidget *widget, m_toolWidgets.value(toolId))
|
||||
activateDock(Qt::DockWidgetArea(widget->property(INITIAL_DOCK_AREA).toInt()), widget);
|
||||
|
||||
loadToolSettings(action);
|
||||
|
||||
QTC_CHECK(m_controlsWidgetFromTool.contains(tool));
|
||||
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(tool));
|
||||
QTC_CHECK(m_controlsWidgetFromTool.contains(toolId));
|
||||
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId));
|
||||
m_toolBox->setCurrentIndex(actionIndex);
|
||||
|
||||
updateRunActions();
|
||||
@@ -533,7 +533,7 @@ void AnalyzerManagerPrivate::addAction(AnalyzerAction *action)
|
||||
|
||||
Id menuGroup = action->menuGroup();
|
||||
if (menuGroup.isValid()) {
|
||||
Command *command = ActionManager::registerAction(action, action->id(), Context(C_GLOBAL));
|
||||
Command *command = ActionManager::registerAction(action, action->actionId(), Context(C_GLOBAL));
|
||||
m_menu->addAction(command, menuGroup);
|
||||
}
|
||||
|
||||
@@ -560,11 +560,11 @@ void AnalyzerManagerPrivate::loadToolSettings(AnalyzerAction *action)
|
||||
{
|
||||
QTC_ASSERT(m_mainWindow, return);
|
||||
QSettings *settings = ICore::settings();
|
||||
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->id().toString());
|
||||
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->toolId().toString());
|
||||
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
|
||||
m_mainWindow->restoreSettings(settings);
|
||||
else
|
||||
m_mainWindow->restoreSettings(m_defaultSettings.value(action->tool()));
|
||||
m_mainWindow->restoreSettings(m_defaultSettings.value(action->toolId()));
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
@@ -574,11 +574,11 @@ void AnalyzerManagerPrivate::saveToolSettings(AnalyzerAction *action)
|
||||
QTC_ASSERT(m_mainWindow, return);
|
||||
|
||||
QSettings *settings = ICore::settings();
|
||||
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->id().toString());
|
||||
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->toolId().toString());
|
||||
m_mainWindow->saveSettings(settings);
|
||||
settings->setValue(QLatin1String("ToolSettingsSaved"), true);
|
||||
settings->endGroup();
|
||||
settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), action->id().toString());
|
||||
settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), action->toolId().toString());
|
||||
}
|
||||
|
||||
void AnalyzerManagerPrivate::updateRunActions()
|
||||
@@ -633,21 +633,21 @@ void AnalyzerManager::addAction(AnalyzerAction *action)
|
||||
d->addAction(action);
|
||||
}
|
||||
|
||||
QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool,
|
||||
QDockWidget *AnalyzerManager::createDockWidget(Core::Id toolId,
|
||||
QWidget *widget, Qt::DockWidgetArea area)
|
||||
{
|
||||
QTC_ASSERT(!widget->objectName().isEmpty(), return 0);
|
||||
QDockWidget *dockWidget = d->m_mainWindow->addDockForWidget(widget);
|
||||
dockWidget->setProperty(INITIAL_DOCK_AREA, int(area));
|
||||
d->m_dockWidgets.append(AnalyzerManagerPrivate::DockPtr(dockWidget));
|
||||
d->m_toolWidgets[tool].push_back(dockWidget);
|
||||
d->m_toolWidgets[toolId].push_back(dockWidget);
|
||||
return dockWidget;
|
||||
}
|
||||
|
||||
void AnalyzerManager::selectTool(IAnalyzerTool *tool, StartMode mode)
|
||||
void AnalyzerManager::selectTool(Id toolId, StartMode mode)
|
||||
{
|
||||
foreach (AnalyzerAction *action, d->m_actions)
|
||||
if (action->tool() == tool && action->startMode() == mode)
|
||||
if (action->toolId() == toolId && action->startMode() == mode)
|
||||
d->selectAction(action);
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ FancyMainWindow *AnalyzerManager::mainWindow()
|
||||
void AnalyzerManagerPrivate::resetLayout()
|
||||
{
|
||||
QTC_ASSERT(m_currentAction, return);
|
||||
m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentAction->tool()));
|
||||
m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentAction->toolId()));
|
||||
}
|
||||
|
||||
void AnalyzerManager::showStatusMessage(const QString &message, int timeoutMS)
|
||||
@@ -708,7 +708,7 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(
|
||||
{
|
||||
foreach (AnalyzerAction *action, d->m_actions) {
|
||||
if (action->runMode() == sp.runMode && action->startMode() == sp.startMode)
|
||||
return action->tool()->createRunControl(sp, runConfiguration);
|
||||
return action->createRunControl(sp, runConfiguration);
|
||||
}
|
||||
QTC_CHECK(false);
|
||||
return 0;
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include "analyzerbase_global.h"
|
||||
#include "analyzerconstants.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -49,7 +50,6 @@ namespace ProjectExplorer { class RunConfiguration; }
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
class IAnalyzerTool;
|
||||
class AnalyzerAction;
|
||||
class AnalyzerRunControl;
|
||||
class AnalyzerStartParameters;
|
||||
@@ -70,13 +70,13 @@ public:
|
||||
static void addAction(AnalyzerAction *action);
|
||||
|
||||
// Dockwidgets are registered to the main window.
|
||||
static QDockWidget *createDockWidget(IAnalyzerTool *tool,
|
||||
static QDockWidget *createDockWidget(Core::Id toolId,
|
||||
QWidget *widget, Qt::DockWidgetArea area = Qt::BottomDockWidgetArea);
|
||||
|
||||
static Utils::FancyMainWindow *mainWindow();
|
||||
|
||||
static void showMode();
|
||||
static void selectTool(IAnalyzerTool *tool, StartMode mode);
|
||||
static void selectTool(Core::Id toolId, StartMode mode);
|
||||
static void startTool();
|
||||
static void stopTool();
|
||||
|
||||
|
@@ -58,41 +58,24 @@ using namespace ProjectExplorer;
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
IAnalyzerTool::IAnalyzerTool(QObject *parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
ProjectExplorer::RunMode AnalyzerAction::runMode() const
|
||||
{
|
||||
return m_runMode;
|
||||
}
|
||||
|
||||
void AnalyzerAction::setRunMode(ProjectExplorer::RunMode mode)
|
||||
{
|
||||
m_runMode = mode;
|
||||
}
|
||||
|
||||
AnalyzerAction::AnalyzerAction(QObject *parent)
|
||||
: QAction(parent)
|
||||
{}
|
||||
|
||||
static bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
|
||||
BuildConfiguration::BuildType buildType)
|
||||
static bool buildTypeAccepted(ToolMode toolMode, BuildConfiguration::BuildType buildType)
|
||||
{
|
||||
if (toolMode == IAnalyzerTool::AnyMode)
|
||||
if (toolMode == AnyMode)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Unknown)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Debug
|
||||
&& toolMode == IAnalyzerTool::DebugMode)
|
||||
if (buildType == BuildConfiguration::Debug && toolMode == DebugMode)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Release
|
||||
&& toolMode == IAnalyzerTool::ReleaseMode)
|
||||
if (buildType == BuildConfiguration::Release && toolMode == ReleaseMode)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool checkForLocalStart(IAnalyzerTool::ToolMode toolMode)
|
||||
bool checkForLocalStart(ToolMode toolMode)
|
||||
{
|
||||
// Make sure mode is shown.
|
||||
AnalyzerManager::showMode();
|
||||
@@ -117,10 +100,10 @@ bool checkForLocalStart(IAnalyzerTool::ToolMode toolMode)
|
||||
|
||||
QString toolModeString;
|
||||
switch (toolMode) {
|
||||
case IAnalyzerTool::DebugMode:
|
||||
case DebugMode:
|
||||
toolModeString = AnalyzerManager::tr("Debug");
|
||||
break;
|
||||
case IAnalyzerTool::ReleaseMode:
|
||||
case ReleaseMode:
|
||||
toolModeString = AnalyzerManager::tr("Release");
|
||||
break;
|
||||
default:
|
||||
|
@@ -41,61 +41,28 @@
|
||||
#include <QObject>
|
||||
#include <QAction>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace ProjectExplorer { class RunConfiguration; }
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
class AnalyzerRunControl;
|
||||
|
||||
|
||||
/**
|
||||
* This class represents an analyzation tool, e.g. "Valgrind Memcheck".
|
||||
* The mode in which this tool should preferably be run
|
||||
*
|
||||
* Each tool can run in different run modes. The modes are specific to the tool.
|
||||
*
|
||||
* @code
|
||||
* bool YourPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
* {
|
||||
* AnalyzerManager::addTool(new MemcheckTool(this));
|
||||
* return true;
|
||||
* }
|
||||
* @endcode
|
||||
* The memcheck tool, for example, requires debug symbols, hence DebugMode
|
||||
* is preferred. On the other hand, callgrind should look at optimized code,
|
||||
* hence ReleaseMode.
|
||||
*/
|
||||
class ANALYZER_EXPORT IAnalyzerTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IAnalyzerTool(QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* The mode in which this tool should preferably be run
|
||||
*
|
||||
* The memcheck tool, for example, requires debug symbols, hence DebugMode
|
||||
* is preferred. On the other hand, callgrind should look at optimized code,
|
||||
* hence ReleaseMode.
|
||||
*/
|
||||
enum ToolMode {
|
||||
DebugMode,
|
||||
ReleaseMode,
|
||||
AnyMode
|
||||
};
|
||||
|
||||
/// Creates all widgets used by the tool.
|
||||
/// Returns a control widget which will be shown in the status bar when
|
||||
/// this tool is selected. Must be non-zero.
|
||||
virtual QWidget *createWidgets() = 0;
|
||||
|
||||
/// Returns a new engine for the given start parameters.
|
||||
/// Called each time the tool is launched.
|
||||
virtual AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) = 0;
|
||||
|
||||
virtual void startTool(StartMode mode) = 0;
|
||||
|
||||
enum ToolMode {
|
||||
DebugMode,
|
||||
ReleaseMode,
|
||||
AnyMode
|
||||
};
|
||||
|
||||
ANALYZER_EXPORT bool checkForLocalStart(IAnalyzerTool::ToolMode toolMode);
|
||||
ANALYZER_EXPORT bool checkForLocalStart(ToolMode toolMode);
|
||||
ANALYZER_EXPORT bool checkForRemoteStart(AnalyzerStartParameters *sp);
|
||||
|
||||
|
||||
@@ -112,30 +79,52 @@ public:
|
||||
explicit AnalyzerAction(QObject *parent = 0);
|
||||
|
||||
public:
|
||||
IAnalyzerTool *tool() const { return m_tool; }
|
||||
void setTool(IAnalyzerTool *tool) { m_tool = tool; }
|
||||
|
||||
StartMode startMode() const { return m_startMode; }
|
||||
void setStartMode(StartMode startMode) { m_startMode = startMode; }
|
||||
|
||||
Core::Id menuGroup() const { return m_menuGroup; }
|
||||
void setMenuGroup(Core::Id menuGroup) { m_menuGroup = menuGroup; }
|
||||
|
||||
Core::Id id() const { return m_id; }
|
||||
void setId(Core::Id id) { m_id = id; }
|
||||
Core::Id actionId() const { return m_actionId; }
|
||||
void setActionId(Core::Id id) { m_actionId = id; }
|
||||
|
||||
ProjectExplorer::RunMode runMode() const;
|
||||
void setRunMode(ProjectExplorer::RunMode mode);
|
||||
Core::Id toolId() const { return m_toolId; }
|
||||
void setToolId(Core::Id id) { m_toolId = id; }
|
||||
|
||||
ProjectExplorer::RunMode runMode() const { return m_runMode; }
|
||||
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; }
|
||||
|
||||
/// Creates all widgets used by the tool.
|
||||
/// Returns a control widget which will be shown in the status bar when
|
||||
/// this tool is selected.
|
||||
typedef std::function<QWidget *()> WidgetCreator;
|
||||
QWidget *createWidget() const { return m_widgetCreator(); }
|
||||
void setWidgetCreator(const WidgetCreator &creator) { m_widgetCreator = creator; }
|
||||
|
||||
/// Returns a new engine for the given start parameters.
|
||||
/// Called each time the tool is launched.
|
||||
typedef std::function<AnalyzerRunControl *(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration)> RunControlCreator;
|
||||
AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) const
|
||||
{ return m_runControlCreator(sp, runConfiguration); }
|
||||
void setRunControlCreator(const RunControlCreator &creator) { m_runControlCreator = creator; }
|
||||
|
||||
typedef std::function<void(StartMode)> ToolStarter;
|
||||
ToolStarter toolStarter() const { return m_toolStarter; }
|
||||
void setToolStarter(const ToolStarter &toolStarter) { m_toolStarter = toolStarter; }
|
||||
|
||||
protected:
|
||||
IAnalyzerTool *m_tool;
|
||||
StartMode m_startMode;
|
||||
Core::Id m_menuGroup;
|
||||
Core::Id m_id;
|
||||
Core::Id m_actionId;
|
||||
Core::Id m_toolId;
|
||||
ProjectExplorer::RunMode m_runMode;
|
||||
WidgetCreator m_widgetCreator;
|
||||
RunControlCreator m_runControlCreator;
|
||||
ToolStarter m_toolStarter;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Analyzer
|
||||
|
||||
#endif // IANALYZERTOOL_H
|
||||
|
@@ -52,7 +52,13 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
|
||||
IAnalyzerTool *tool = new QmlProfilerTool(this);
|
||||
auto tool = new QmlProfilerTool(this);
|
||||
auto toolStarter = [tool](StartMode mode) { return tool->startTool(mode); };
|
||||
auto widgetCreator = [tool] { return tool->createWidgets(); };
|
||||
auto runControlCreator = [tool](const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) {
|
||||
return tool->createRunControl(sp, runConfiguration);
|
||||
};
|
||||
|
||||
AnalyzerAction *action = 0;
|
||||
|
||||
@@ -61,8 +67,11 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
"applications using QML.");
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("QmlProfiler.Local");
|
||||
action->setTool(tool);
|
||||
action->setActionId("QmlProfiler.Local");
|
||||
action->setToolId(QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolStarter(toolStarter);
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler"));
|
||||
action->setToolTip(description);
|
||||
@@ -71,8 +80,11 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
AnalyzerManager::addAction(action);
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("QmlProfiler.Remote");
|
||||
action->setTool(tool);
|
||||
action->setActionId("QmlProfiler.Remote");
|
||||
action->setToolId(QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolStarter(toolStarter);
|
||||
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
|
||||
action->setText(tr("QML Profiler (External)"));
|
||||
action->setToolTip(description);
|
||||
|
@@ -121,7 +121,7 @@ public:
|
||||
};
|
||||
|
||||
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate)
|
||||
: QObject(parent), d(new QmlProfilerToolPrivate)
|
||||
{
|
||||
setObjectName(QLatin1String("QmlProfilerTool"));
|
||||
|
||||
@@ -486,7 +486,7 @@ void QmlProfilerTool::clearDisplay()
|
||||
updateTimeDisplay();
|
||||
}
|
||||
|
||||
static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
|
||||
static void startRemoteTool(QmlProfilerTool *tool, StartMode mode)
|
||||
{
|
||||
Id kitId;
|
||||
quint16 port;
|
||||
@@ -601,7 +601,7 @@ void QmlProfilerTool::showLoadDialog()
|
||||
if (ModeManager::currentMode()->id() != MODE_ANALYZE)
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
AnalyzerManager::selectTool(this, StartRemote);
|
||||
AnalyzerManager::selectTool("QmlProfiler", StartRemote);
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(ICore::mainWindow(), tr("Load QML Trace"), QString(),
|
||||
tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension)));
|
||||
|
@@ -42,7 +42,9 @@ QT_END_NAMESPACE
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
class QmlProfilerTool : public Analyzer::IAnalyzerTool
|
||||
const char QmlProfilerToolId[] = "QmlProfiler";
|
||||
|
||||
class QmlProfilerTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -77,7 +77,7 @@ public:
|
||||
QmlProfilerTraceView *q;
|
||||
|
||||
QmlProfilerStateManager *m_profilerState;
|
||||
Analyzer::IAnalyzerTool *m_profilerTool;
|
||||
QmlProfilerTool *m_profilerTool;
|
||||
QmlProfilerViewManager *m_viewContainer;
|
||||
|
||||
QSize m_sizeHint;
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
Timeline::TimelineZoomControl *m_zoomControl;
|
||||
};
|
||||
|
||||
QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState)
|
||||
QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState)
|
||||
: QWidget(parent), d(new QmlProfilerTraceViewPrivate(this))
|
||||
{
|
||||
setObjectName(QLatin1String("QML Profiler"));
|
||||
|
@@ -35,14 +35,13 @@
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Analyzer { class IAnalyzerTool; }
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
class QmlProfilerModelManager;
|
||||
namespace Internal {
|
||||
|
||||
class QmlProfilerStateManager;
|
||||
class QmlProfilerTool;
|
||||
class QmlProfilerViewManager;
|
||||
|
||||
class QmlProfilerTraceView : public QWidget
|
||||
@@ -50,7 +49,7 @@ class QmlProfilerTraceView : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool,
|
||||
explicit QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *profilerTool,
|
||||
QmlProfilerViewManager *container,
|
||||
QmlProfilerModelManager *modelManager,
|
||||
QmlProfilerStateManager *profilerState);
|
||||
|
@@ -124,11 +124,11 @@ void QmlProfilerViewManager::createViews()
|
||||
d->v8profilerView, SLOT(selectBySourceLocation(QString,int,int)));
|
||||
|
||||
QDockWidget *eventsDock = AnalyzerManager::createDockWidget
|
||||
(d->profilerTool, d->eventsView);
|
||||
(QmlProfilerToolId, d->eventsView);
|
||||
QDockWidget *timelineDock = AnalyzerManager::createDockWidget
|
||||
(d->profilerTool, d->traceView);
|
||||
(QmlProfilerToolId, d->traceView);
|
||||
QDockWidget *v8profilerDock = AnalyzerManager::createDockWidget
|
||||
(d->profilerTool, d->v8profilerView);
|
||||
(QmlProfilerToolId, d->v8profilerView);
|
||||
|
||||
eventsDock->show();
|
||||
timelineDock->show();
|
||||
|
@@ -104,7 +104,7 @@ public:
|
||||
|
||||
QV8ProfilerEventsWidget *q;
|
||||
|
||||
Analyzer::IAnalyzerTool *m_profilerTool;
|
||||
QmlProfilerTool *m_profilerTool;
|
||||
QmlProfilerViewManager *m_viewContainer;
|
||||
|
||||
QV8ProfilerEventsMainView *m_eventTree;
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
};
|
||||
|
||||
QV8ProfilerEventsWidget::QV8ProfilerEventsWidget(QWidget *parent,
|
||||
Analyzer::IAnalyzerTool *profilerTool,
|
||||
QmlProfilerTool *profilerTool,
|
||||
QmlProfilerViewManager *container,
|
||||
QmlProfilerModelManager *profilerModelManager )
|
||||
: QWidget(parent), d(new QV8ProfilerEventsWidgetPrivate(this))
|
||||
|
@@ -55,7 +55,7 @@ class QV8ProfilerEventsWidget : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QV8ProfilerEventsWidget(QWidget *parent,
|
||||
Analyzer::IAnalyzerTool *profilerTool,
|
||||
QmlProfilerTool *profilerTool,
|
||||
QmlProfilerViewManager *container,
|
||||
QmlProfilerModelManager *profilerModelManager );
|
||||
~QV8ProfilerEventsWidget();
|
||||
|
@@ -500,7 +500,7 @@ static QToolButton *createToolButton(QAction *action)
|
||||
}
|
||||
|
||||
CallgrindTool::CallgrindTool(QObject *parent)
|
||||
: IAnalyzerTool(parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
d = new CallgrindToolPrivate(this);
|
||||
setObjectName(QLatin1String("CallgrindTool"));
|
||||
@@ -643,11 +643,11 @@ QWidget *CallgrindToolPrivate::createWidgets()
|
||||
|
||||
updateCostFormat();
|
||||
|
||||
QDockWidget *callersDock = AnalyzerManager::createDockWidget(q, m_callersView);
|
||||
QDockWidget *flatDock = AnalyzerManager::createDockWidget(q, m_flatView);
|
||||
QDockWidget *calleesDock = AnalyzerManager::createDockWidget(q, m_calleesView);
|
||||
QDockWidget *callersDock = AnalyzerManager::createDockWidget(CallgrindToolId, m_callersView);
|
||||
QDockWidget *flatDock = AnalyzerManager::createDockWidget(CallgrindToolId, m_flatView);
|
||||
QDockWidget *calleesDock = AnalyzerManager::createDockWidget(CallgrindToolId, m_calleesView);
|
||||
QDockWidget *visualizationDock = AnalyzerManager::createDockWidget
|
||||
(q, m_visualisation, Qt::RightDockWidgetArea);
|
||||
(CallgrindToolId, m_visualisation, Qt::RightDockWidgetArea);
|
||||
|
||||
callersDock->show();
|
||||
calleesDock->show();
|
||||
@@ -925,7 +925,7 @@ void CallgrindToolPrivate::handleShowCostsOfFunction()
|
||||
|
||||
m_toggleCollectFunction = qualifiedFunctionName + QLatin1String("()");
|
||||
|
||||
AnalyzerManager::selectTool(q, StartLocal);
|
||||
AnalyzerManager::selectTool(CallgrindToolId, StartLocal);
|
||||
AnalyzerManager::startTool();
|
||||
}
|
||||
|
||||
|
@@ -36,9 +36,11 @@
|
||||
namespace Valgrind {
|
||||
namespace Internal {
|
||||
|
||||
const char CallgrindToolId[] = "Callgrind";
|
||||
|
||||
class CallgrindToolPrivate;
|
||||
|
||||
class CallgrindTool : public Analyzer::IAnalyzerTool
|
||||
class CallgrindTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -187,7 +187,7 @@ static void initKindFilterAction(QAction *action, const QList<int> &kinds)
|
||||
}
|
||||
|
||||
MemcheckTool::MemcheckTool(QObject *parent)
|
||||
: IAnalyzerTool(parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_settings = 0;
|
||||
m_errorModel = 0;
|
||||
@@ -358,7 +358,7 @@ QWidget *MemcheckTool::createWidgets()
|
||||
m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView"));
|
||||
m_errorView->setWindowTitle(tr("Memory Issues"));
|
||||
|
||||
QDockWidget *errorDock = AnalyzerManager::createDockWidget(this, m_errorView);
|
||||
QDockWidget *errorDock = AnalyzerManager::createDockWidget("Memcheck", m_errorView);
|
||||
errorDock->show();
|
||||
mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical);
|
||||
|
||||
|
@@ -76,13 +76,19 @@ private:
|
||||
bool m_filterExternalIssues;
|
||||
};
|
||||
|
||||
class MemcheckTool : public Analyzer::IAnalyzerTool
|
||||
class MemcheckTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MemcheckTool(QObject *parent);
|
||||
|
||||
void startTool(Analyzer::StartMode mode);
|
||||
QWidget *createWidgets();
|
||||
|
||||
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0);
|
||||
|
||||
private slots:
|
||||
void settingsDestroyed(QObject *settings);
|
||||
void maybeActiveRunConfigurationChanged();
|
||||
@@ -99,8 +105,6 @@ private slots:
|
||||
void loadExternalXmlLogFile();
|
||||
|
||||
private:
|
||||
void startTool(Analyzer::StartMode mode);
|
||||
QWidget *createWidgets();
|
||||
void setBusyCursor(bool busy);
|
||||
|
||||
void clearErrorView();
|
||||
@@ -108,9 +112,6 @@ private:
|
||||
int updateUiAfterFinishedHelper();
|
||||
|
||||
protected:
|
||||
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0);
|
||||
|
||||
virtual MemcheckRunControl *createMemcheckRunControl(
|
||||
const Analyzer::AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration);
|
||||
@@ -138,7 +139,6 @@ class MemcheckWithGdbTool : public MemcheckTool
|
||||
public:
|
||||
MemcheckWithGdbTool(QObject *parent);
|
||||
|
||||
protected:
|
||||
void startTool(Analyzer::StartMode mode);
|
||||
MemcheckRunControl *createMemcheckRunControl(
|
||||
const Analyzer::AnalyzerStartParameters &sp,
|
||||
|
@@ -124,10 +124,37 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
"Valgrind Analyze Memory with GDB uses the \"memcheck\" tool to find memory leaks.\n"
|
||||
"When a problem is detected, the application is interrupted and can be debugged");
|
||||
|
||||
MemcheckTool *mcTool = m_memcheckTool;
|
||||
auto mcToolStarter = [mcTool](StartMode mode) { return mcTool->startTool(mode); };
|
||||
auto mcWidgetCreator = [mcTool] { return mcTool->createWidgets(); };
|
||||
auto mcRunControlCreator = [mcTool](const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) {
|
||||
return mcTool->createRunControl(sp, runConfiguration);
|
||||
};
|
||||
|
||||
MemcheckWithGdbTool *mcgTool = m_memcheckWithGdbTool;
|
||||
auto mcgToolStarter = [mcgTool](StartMode mode) { return mcgTool->startTool(mode); };
|
||||
auto mcgWidgetCreator = [mcgTool] { return mcgTool->createWidgets(); };
|
||||
auto mcgRunControlCreator = [mcgTool](const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) {
|
||||
return mcgTool->createRunControl(sp, runConfiguration);
|
||||
};
|
||||
|
||||
CallgrindTool *cgTool = m_callgrindTool;
|
||||
auto cgToolStarter = [cgTool](StartMode mode) { return cgTool->startTool(mode); };
|
||||
auto cgWidgetCreator = [cgTool] { return cgTool->createWidgets(); };
|
||||
auto cgRunControlCreator = [cgTool](const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) {
|
||||
return cgTool->createRunControl(sp, runConfiguration);
|
||||
};
|
||||
|
||||
if (!Utils::HostOsInfo::isWindowsHost()) {
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Memcheck.Local");
|
||||
action->setTool(m_memcheckTool);
|
||||
action->setActionId("Memcheck.Local");
|
||||
action->setToolId("Memcheck");
|
||||
action->setWidgetCreator(mcWidgetCreator);
|
||||
action->setRunControlCreator(mcRunControlCreator);
|
||||
action->setToolStarter(mcToolStarter);
|
||||
action->setRunMode(ProjectExplorer::MemcheckRunMode);
|
||||
action->setText(tr("Valgrind Memory Analyzer"));
|
||||
action->setToolTip(memcheckToolTip);
|
||||
@@ -137,8 +164,11 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
AnalyzerManager::addAction(action);
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("MemcheckWithGdb.Local");
|
||||
action->setTool(m_memcheckWithGdbTool);
|
||||
action->setActionId("MemcheckWithGdb.Local");
|
||||
action->setToolId("MemcheckWithGdb");
|
||||
action->setWidgetCreator(mcgWidgetCreator);
|
||||
action->setRunControlCreator(mcgRunControlCreator);
|
||||
action->setToolStarter(mcgToolStarter);
|
||||
action->setRunMode(ProjectExplorer::MemcheckWithGdbRunMode);
|
||||
action->setText(tr("Valgrind Memory Analyzer with GDB"));
|
||||
action->setToolTip(memcheckWithGdbToolTip);
|
||||
@@ -148,8 +178,11 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
AnalyzerManager::addAction(action);
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Callgrind.Local");
|
||||
action->setTool(m_callgrindTool);
|
||||
action->setActionId("Callgrind.Local");
|
||||
action->setToolId(CallgrindToolId);
|
||||
action->setWidgetCreator(cgWidgetCreator);
|
||||
action->setRunControlCreator(cgRunControlCreator);
|
||||
action->setToolStarter(cgToolStarter);
|
||||
action->setRunMode(ProjectExplorer::CallgrindRunMode);
|
||||
action->setText(tr("Valgrind Function Profiler"));
|
||||
action->setToolTip(callgrindToolTip);
|
||||
@@ -160,8 +193,11 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
}
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Memcheck.Remote");
|
||||
action->setTool(m_memcheckTool);
|
||||
action->setActionId("Memcheck.Remote");
|
||||
action->setToolId("Memcheck");
|
||||
action->setWidgetCreator(mcWidgetCreator);
|
||||
action->setRunControlCreator(mcRunControlCreator);
|
||||
action->setToolStarter(mcToolStarter);
|
||||
action->setRunMode(ProjectExplorer::MemcheckRunMode);
|
||||
action->setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
|
||||
action->setToolTip(memcheckToolTip);
|
||||
@@ -170,8 +206,11 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
AnalyzerManager::addAction(action);
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setId("Callgrind.Remote");
|
||||
action->setTool(m_callgrindTool);
|
||||
action->setActionId("Callgrind.Remote");
|
||||
action->setToolId(CallgrindToolId);
|
||||
action->setWidgetCreator(cgWidgetCreator);
|
||||
action->setRunControlCreator(cgRunControlCreator);
|
||||
action->setToolStarter(cgToolStarter);
|
||||
action->setRunMode(ProjectExplorer::CallgrindRunMode);
|
||||
action->setText(tr("Valgrind Function Profiler (External Remote Application)"));
|
||||
action->setToolTip(callgrindToolTip);
|
||||
|
Reference in New Issue
Block a user