Analyzer: Move non-static parts of IAnalyzerTool::start*Tool

... to user code.

Change-Id: Ibe278134e39cfb3f90acedc976fab5e9dc019046
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-18 12:25:39 +01:00
parent 05f8a2c813
commit ca04d009f2
5 changed files with 56 additions and 36 deletions

View File

@@ -92,7 +92,7 @@ static bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
return false; return false;
} }
void IAnalyzerTool::startLocalTool(ToolMode toolMode, RunMode runMode) bool checkForLocalStart(IAnalyzerTool::ToolMode toolMode)
{ {
// Make sure mode is shown. // Make sure mode is shown.
AnalyzerManager::showMode(); AnalyzerManager::showMode();
@@ -140,29 +140,26 @@ void IAnalyzerTool::startLocalTool(ToolMode toolMode, RunMode runMode)
if (Utils::CheckableMessageBox::doNotAskAgainQuestion(ICore::mainWindow(), if (Utils::CheckableMessageBox::doNotAskAgainQuestion(ICore::mainWindow(),
title, message, ICore::settings(), QLatin1String("AnalyzerCorrectModeWarning")) title, message, ICore::settings(), QLatin1String("AnalyzerCorrectModeWarning"))
!= QDialogButtonBox::Yes) != QDialogButtonBox::Yes)
return; return false;
} }
ProjectExplorerPlugin::instance()->runProject(pro, runMode); return true;
} }
void IAnalyzerTool::startRemoteTool(RunMode runMode) bool checkForRemoteStart(AnalyzerStartParameters *sp)
{ {
StartRemoteDialog dlg; StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
return; return false;
AnalyzerStartParameters sp; sp->startMode = StartRemote;
sp.startMode = StartRemote; sp->connParams = dlg.sshParams();
sp.connParams = dlg.sshParams(); sp->debuggee = dlg.executable();
sp.debuggee = dlg.executable(); sp->debuggeeArgs = dlg.arguments();
sp.debuggeeArgs = dlg.arguments(); sp->displayName = dlg.executable();
sp.displayName = dlg.executable(); sp->workingDirectory = dlg.workingDirectory();
sp.workingDirectory = dlg.workingDirectory();
AnalyzerRunControl *rc = createRunControl(sp, 0); return true;
ProjectExplorerPlugin::startRunControl(rc, runMode);
} }
} // namespace Analyzer } // namespace Analyzer

View File

@@ -93,10 +93,12 @@ public:
virtual void startTool(StartMode mode) = 0; virtual void startTool(StartMode mode) = 0;
void startLocalTool(ToolMode toolMode, ProjectExplorer::RunMode runMode);
void startRemoteTool(ProjectExplorer::RunMode runMode);
}; };
ANALYZER_EXPORT bool checkForLocalStart(IAnalyzerTool::ToolMode toolMode);
ANALYZER_EXPORT bool checkForRemoteStart(AnalyzerStartParameters *sp);
/** /**
* This class represents an analyzation action, i.e. a tool that runs in a specific mode. * This class represents an analyzation action, i.e. a tool that runs in a specific mode.
* *

View File

@@ -57,7 +57,10 @@
#include <cplusplus/LookupContext.h> #include <cplusplus/LookupContext.h>
#include <cplusplus/Overview.h> #include <cplusplus/Overview.h>
#include <cplusplus/Symbols.h>
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -65,7 +68,9 @@
#include <utils/styledbar.h> #include <utils/styledbar.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projecttree.h> #include <projectexplorer/projecttree.h>
#include <projectexplorer/session.h>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
@@ -87,9 +92,6 @@
#include <QToolButton> #include <QToolButton>
#include <QVBoxLayout> #include <QVBoxLayout>
// shared/cplusplus includes
#include <cplusplus/Symbols.h>
using namespace Analyzer; using namespace Analyzer;
using namespace Core; using namespace Core;
using namespace Valgrind::Callgrind; using namespace Valgrind::Callgrind;
@@ -558,11 +560,18 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa
void CallgrindTool::startTool(StartMode mode) void CallgrindTool::startTool(StartMode mode)
{ {
if (mode == StartLocal) if (mode == StartLocal && checkForLocalStart(ReleaseMode)) {
startLocalTool(ReleaseMode, CallgrindRunMode); Project *pro = SessionManager::startupProject();
if (mode == StartRemote) ProjectExplorerPlugin::instance()->runProject(pro, CallgrindRunMode);
startRemoteTool(CallgrindRunMode);
d->setBusyCursor(true); d->setBusyCursor(true);
}
AnalyzerStartParameters sp;
if (mode == StartRemote && checkForRemoteStart(&sp)) {
AnalyzerRunControl *rc = createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, CallgrindRunMode);
d->setBusyCursor(true);
}
} }
void CallgrindTool::handleShowCostsOfFunction() void CallgrindTool::handleShowCostsOfFunction()

View File

@@ -599,10 +599,16 @@ void MemcheckTool::setBusyCursor(bool busy)
void MemcheckTool::startTool(StartMode mode) void MemcheckTool::startTool(StartMode mode)
{ {
if (mode == StartLocal) if (mode == StartLocal && checkForLocalStart(DebugMode)) {
startLocalTool(DebugMode, MemcheckRunMode); Project *pro = SessionManager::startupProject();
if (mode == StartRemote) ProjectExplorerPlugin::instance()->runProject(pro, MemcheckRunMode);
startRemoteTool(MemcheckRunMode); }
AnalyzerStartParameters sp;
if (mode == StartRemote && checkForRemoteStart(&sp)) {
AnalyzerRunControl *rc = createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, MemcheckRunMode);
}
} }
MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) : MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) :
@@ -613,10 +619,16 @@ MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) :
void MemcheckWithGdbTool::startTool(Analyzer::StartMode mode) void MemcheckWithGdbTool::startTool(Analyzer::StartMode mode)
{ {
if (mode == StartLocal) if (mode == StartLocal && checkForLocalStart(DebugMode)) {
startLocalTool(DebugMode, MemcheckWithGdbRunMode); Project *pro = SessionManager::startupProject();
if (mode == StartRemote) ProjectExplorerPlugin::instance()->runProject(pro, MemcheckWithGdbRunMode);
startRemoteTool(MemcheckWithGdbRunMode); }
AnalyzerStartParameters sp;
if (mode == StartRemote && checkForRemoteStart(&sp)) {
AnalyzerRunControl *rc = createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, MemcheckWithGdbRunMode);
}
} }
MemcheckRunControl *MemcheckWithGdbTool::createMemcheckRunControl(const AnalyzerStartParameters &sp, MemcheckRunControl *MemcheckWithGdbTool::createMemcheckRunControl(const AnalyzerStartParameters &sp,

View File

@@ -103,14 +103,14 @@ private:
QWidget *createWidgets(); QWidget *createWidgets();
void setBusyCursor(bool busy); void setBusyCursor(bool busy);
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
void clearErrorView(); void clearErrorView();
void updateFromSettings(); void updateFromSettings();
int updateUiAfterFinishedHelper(); int updateUiAfterFinishedHelper();
protected: protected:
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
virtual MemcheckRunControl *createMemcheckRunControl( virtual MemcheckRunControl *createMemcheckRunControl(
const Analyzer::AnalyzerStartParameters &sp, const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration); ProjectExplorer::RunConfiguration *runConfiguration);