From ca04d009f20f0efea501bb721fda1fed51278242 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 18 Feb 2015 12:25:39 +0100 Subject: [PATCH] Analyzer: Move non-static parts of IAnalyzerTool::start*Tool ... to user code. Change-Id: Ibe278134e39cfb3f90acedc976fab5e9dc019046 Reviewed-by: Christian Stenger --- src/plugins/analyzerbase/ianalyzertool.cpp | 27 ++++++++++----------- src/plugins/analyzerbase/ianalyzertool.h | 6 +++-- src/plugins/valgrind/callgrindtool.cpp | 25 ++++++++++++------- src/plugins/valgrind/memchecktool.cpp | 28 +++++++++++++++------- src/plugins/valgrind/memchecktool.h | 6 ++--- 5 files changed, 56 insertions(+), 36 deletions(-) diff --git a/src/plugins/analyzerbase/ianalyzertool.cpp b/src/plugins/analyzerbase/ianalyzertool.cpp index 43007be1a42..86d2010f0f6 100644 --- a/src/plugins/analyzerbase/ianalyzertool.cpp +++ b/src/plugins/analyzerbase/ianalyzertool.cpp @@ -92,7 +92,7 @@ static bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode, return false; } -void IAnalyzerTool::startLocalTool(ToolMode toolMode, RunMode runMode) +bool checkForLocalStart(IAnalyzerTool::ToolMode toolMode) { // Make sure mode is shown. AnalyzerManager::showMode(); @@ -140,29 +140,26 @@ void IAnalyzerTool::startLocalTool(ToolMode toolMode, RunMode runMode) if (Utils::CheckableMessageBox::doNotAskAgainQuestion(ICore::mainWindow(), title, message, ICore::settings(), QLatin1String("AnalyzerCorrectModeWarning")) != QDialogButtonBox::Yes) - return; + return false; } - ProjectExplorerPlugin::instance()->runProject(pro, runMode); + return true; } -void IAnalyzerTool::startRemoteTool(RunMode runMode) +bool checkForRemoteStart(AnalyzerStartParameters *sp) { StartRemoteDialog dlg; if (dlg.exec() != QDialog::Accepted) - return; + return false; - AnalyzerStartParameters sp; - sp.startMode = StartRemote; - sp.connParams = dlg.sshParams(); - sp.debuggee = dlg.executable(); - sp.debuggeeArgs = dlg.arguments(); - sp.displayName = dlg.executable(); - sp.workingDirectory = dlg.workingDirectory(); + sp->startMode = StartRemote; + sp->connParams = dlg.sshParams(); + sp->debuggee = dlg.executable(); + sp->debuggeeArgs = dlg.arguments(); + sp->displayName = dlg.executable(); + sp->workingDirectory = dlg.workingDirectory(); - AnalyzerRunControl *rc = createRunControl(sp, 0); - - ProjectExplorerPlugin::startRunControl(rc, runMode); + return true; } } // namespace Analyzer diff --git a/src/plugins/analyzerbase/ianalyzertool.h b/src/plugins/analyzerbase/ianalyzertool.h index 1c679c90921..07de7f79697 100644 --- a/src/plugins/analyzerbase/ianalyzertool.h +++ b/src/plugins/analyzerbase/ianalyzertool.h @@ -93,10 +93,12 @@ public: 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. * diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 64a9061a55a..dcaaee14089 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -57,7 +57,10 @@ #include #include +#include + #include + #include #include @@ -65,7 +68,9 @@ #include #include +#include #include +#include #include #include @@ -87,9 +92,6 @@ #include #include -// shared/cplusplus includes -#include - using namespace Analyzer; using namespace Core; using namespace Valgrind::Callgrind; @@ -558,11 +560,18 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa void CallgrindTool::startTool(StartMode mode) { - if (mode == StartLocal) - startLocalTool(ReleaseMode, CallgrindRunMode); - if (mode == StartRemote) - startRemoteTool(CallgrindRunMode); - d->setBusyCursor(true); + if (mode == StartLocal && checkForLocalStart(ReleaseMode)) { + Project *pro = SessionManager::startupProject(); + ProjectExplorerPlugin::instance()->runProject(pro, CallgrindRunMode); + 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() diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 43acdbff60c..918089333f0 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -599,10 +599,16 @@ void MemcheckTool::setBusyCursor(bool busy) void MemcheckTool::startTool(StartMode mode) { - if (mode == StartLocal) - startLocalTool(DebugMode, MemcheckRunMode); - if (mode == StartRemote) - startRemoteTool(MemcheckRunMode); + if (mode == StartLocal && checkForLocalStart(DebugMode)) { + Project *pro = SessionManager::startupProject(); + ProjectExplorerPlugin::instance()->runProject(pro, MemcheckRunMode); + } + + AnalyzerStartParameters sp; + if (mode == StartRemote && checkForRemoteStart(&sp)) { + AnalyzerRunControl *rc = createRunControl(sp, 0); + ProjectExplorerPlugin::startRunControl(rc, MemcheckRunMode); + } } MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) : @@ -613,10 +619,16 @@ MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) : void MemcheckWithGdbTool::startTool(Analyzer::StartMode mode) { - if (mode == StartLocal) - startLocalTool(DebugMode, MemcheckWithGdbRunMode); - if (mode == StartRemote) - startRemoteTool(MemcheckWithGdbRunMode); + if (mode == StartLocal && checkForLocalStart(DebugMode)) { + Project *pro = SessionManager::startupProject(); + ProjectExplorerPlugin::instance()->runProject(pro, MemcheckWithGdbRunMode); + } + + AnalyzerStartParameters sp; + if (mode == StartRemote && checkForRemoteStart(&sp)) { + AnalyzerRunControl *rc = createRunControl(sp, 0); + ProjectExplorerPlugin::startRunControl(rc, MemcheckWithGdbRunMode); + } } MemcheckRunControl *MemcheckWithGdbTool::createMemcheckRunControl(const AnalyzerStartParameters &sp, diff --git a/src/plugins/valgrind/memchecktool.h b/src/plugins/valgrind/memchecktool.h index 6b73714eb13..b43499c359f 100644 --- a/src/plugins/valgrind/memchecktool.h +++ b/src/plugins/valgrind/memchecktool.h @@ -103,14 +103,14 @@ private: QWidget *createWidgets(); void setBusyCursor(bool busy); - Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, - ProjectExplorer::RunConfiguration *runConfiguration = 0); - void clearErrorView(); void updateFromSettings(); int updateUiAfterFinishedHelper(); protected: + Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, + ProjectExplorer::RunConfiguration *runConfiguration = 0); + virtual MemcheckRunControl *createMemcheckRunControl( const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration);