forked from qt-creator/qt-creator
Analyzer: Move common startTool implementations to IAnalyzerTool base
Change-Id: I963cb2d025a10cee75b9a9648531c4daeb1b70aa Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
This commit is contained in:
@@ -156,7 +156,6 @@ public:
|
||||
QAction *actionFromToolAndMode(IAnalyzerTool *tool, StartMode mode);
|
||||
|
||||
// Convenience.
|
||||
void startLocalTool(IAnalyzerTool *tool);
|
||||
bool isActionRunnable(QAction *action) const;
|
||||
|
||||
public slots:
|
||||
@@ -409,22 +408,6 @@ void AnalyzerManagerPrivate::deactivateDock(QDockWidget *dockWidget)
|
||||
dockWidget->setParent(0);
|
||||
}
|
||||
|
||||
bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
|
||||
BuildConfiguration::BuildType buildType)
|
||||
{
|
||||
if (toolMode == IAnalyzerTool::AnyMode)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Unknown)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Debug
|
||||
&& toolMode == IAnalyzerTool::DebugMode)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Release
|
||||
&& toolMode == IAnalyzerTool::ReleaseMode)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AnalyzerManagerPrivate::showPromptDialog(const QString &title, const QString &text,
|
||||
const QString &stopButtonText, const QString &cancelButtonText) const
|
||||
{
|
||||
@@ -442,83 +425,6 @@ bool AnalyzerManagerPrivate::showPromptDialog(const QString &title, const QStrin
|
||||
return messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
|
||||
}
|
||||
|
||||
void AnalyzerManagerPrivate::startLocalTool(IAnalyzerTool *tool)
|
||||
{
|
||||
int index = m_tools.indexOf(tool);
|
||||
QTC_ASSERT(index >= 0, return);
|
||||
QTC_ASSERT(index < m_tools.size(), return);
|
||||
QTC_ASSERT(tool == m_currentTool, return);
|
||||
|
||||
// Make sure mode is shown.
|
||||
q->showMode();
|
||||
|
||||
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
||||
|
||||
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
||||
Project *pro = pe->startupProject();
|
||||
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
|
||||
if (pro) {
|
||||
if (const Target *target = pro->activeTarget()) {
|
||||
// Build configuration is 0 for QML projects.
|
||||
if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration())
|
||||
buildType = buildConfig->buildType();
|
||||
}
|
||||
}
|
||||
|
||||
IAnalyzerTool::ToolMode toolMode = tool->toolMode();
|
||||
|
||||
// Check the project for whether the build config is in the correct mode
|
||||
// if not, notify the user and urge him to use the correct mode.
|
||||
if (!buildTypeAccepted(toolMode, buildType)) {
|
||||
const QString toolName = tool->displayName();
|
||||
const QString currentMode =
|
||||
buildType == BuildConfiguration::Debug ? tr("Debug") : tr("Release");
|
||||
|
||||
QSettings *settings = ICore::settings();
|
||||
const QString configKey = QLatin1String("Analyzer.AnalyzeCorrectMode");
|
||||
int ret;
|
||||
if (settings->contains(configKey)) {
|
||||
ret = settings->value(configKey, QDialog::Accepted).toInt();
|
||||
} else {
|
||||
QString toolModeString;
|
||||
switch (toolMode) {
|
||||
case IAnalyzerTool::DebugMode:
|
||||
toolModeString = tr("Debug");
|
||||
break;
|
||||
case IAnalyzerTool::ReleaseMode:
|
||||
toolModeString = tr("Release");
|
||||
break;
|
||||
default:
|
||||
QTC_CHECK(false);
|
||||
}
|
||||
const QString title = tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode);
|
||||
const QString message = tr("<html><head/><body><p>You are trying "
|
||||
"to run the tool \"%1\" on an application in %2 mode. "
|
||||
"The tool is designed to be used in %3 mode.</p><p>"
|
||||
"Debug and Release mode run-time characteristics differ "
|
||||
"significantly, analytical findings for one mode may or "
|
||||
"may not be relevant for the other.</p><p>"
|
||||
"Do you want to continue and run the tool in %2 mode?</p></body></html>")
|
||||
.arg(toolName).arg(currentMode).arg(toolModeString);
|
||||
const QString checkBoxText = tr("&Do not ask again");
|
||||
bool checkBoxSetting = false;
|
||||
const QDialogButtonBox::StandardButton button =
|
||||
Utils::CheckableMessageBox::question(ICore::mainWindow(),
|
||||
title, message, checkBoxText,
|
||||
&checkBoxSetting, QDialogButtonBox::Yes|QDialogButtonBox::Cancel,
|
||||
QDialogButtonBox::Cancel);
|
||||
ret = button == QDialogButtonBox::Yes ? QDialog::Accepted : QDialog::Rejected;
|
||||
|
||||
if (checkBoxSetting && ret == QDialog::Accepted)
|
||||
settings->setValue(configKey, ret);
|
||||
}
|
||||
if (ret == QDialog::Rejected)
|
||||
return;
|
||||
}
|
||||
|
||||
pe->runProject(pro, tool->runMode());
|
||||
}
|
||||
|
||||
bool AnalyzerManagerPrivate::isActionRunnable(QAction *action) const
|
||||
{
|
||||
if (!action || m_isRunning)
|
||||
@@ -847,11 +753,6 @@ void AnalyzerManager::stopTool()
|
||||
stopAction()->trigger();
|
||||
}
|
||||
|
||||
void AnalyzerManager::startLocalTool(IAnalyzerTool *tool)
|
||||
{
|
||||
m_instance->d->startLocalTool(tool);
|
||||
}
|
||||
|
||||
QAction *AnalyzerManager::stopAction()
|
||||
{
|
||||
return m_instance->d->m_stopAction;
|
||||
|
@@ -85,8 +85,6 @@ public:
|
||||
static void stopTool();
|
||||
|
||||
// Convenience functions.
|
||||
static void startLocalTool(IAnalyzerTool *tool);
|
||||
|
||||
static QString msgToolStarted(const QString &name);
|
||||
static QString msgToolFinished(const QString &name, int issuesFound);
|
||||
|
||||
|
@@ -30,7 +30,29 @@
|
||||
|
||||
#include "ianalyzertool.h"
|
||||
|
||||
#include "analyzermanager.h"
|
||||
#include "analyzerruncontrol.h"
|
||||
#include "startremotedialog.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/imode.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QSettings>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Analyzer {
|
||||
|
||||
@@ -78,4 +100,119 @@ AbstractAnalyzerSubConfig *IAnalyzerTool::createProjectSettings()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
|
||||
BuildConfiguration::BuildType buildType)
|
||||
{
|
||||
if (toolMode == IAnalyzerTool::AnyMode)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Unknown)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Debug
|
||||
&& toolMode == IAnalyzerTool::DebugMode)
|
||||
return true;
|
||||
if (buildType == BuildConfiguration::Release
|
||||
&& toolMode == IAnalyzerTool::ReleaseMode)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void startLocalTool(IAnalyzerTool *tool)
|
||||
{
|
||||
// Make sure mode is shown.
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
||||
|
||||
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
||||
Project *pro = pe->startupProject();
|
||||
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
|
||||
if (pro) {
|
||||
if (const Target *target = pro->activeTarget()) {
|
||||
// Build configuration is 0 for QML projects.
|
||||
if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration())
|
||||
buildType = buildConfig->buildType();
|
||||
}
|
||||
}
|
||||
|
||||
// Check the project for whether the build config is in the correct mode
|
||||
// if not, notify the user and urge him to use the correct mode.
|
||||
if (!buildTypeAccepted(tool->toolMode(), buildType)) {
|
||||
const QString currentMode = buildType == BuildConfiguration::Debug
|
||||
? AnalyzerManager::tr("Debug")
|
||||
: AnalyzerManager::tr("Release");
|
||||
|
||||
QSettings *settings = ICore::settings();
|
||||
const QString configKey = QLatin1String("Analyzer.AnalyzeCorrectMode");
|
||||
int ret;
|
||||
if (settings->contains(configKey)) {
|
||||
ret = settings->value(configKey, QDialog::Accepted).toInt();
|
||||
} else {
|
||||
QString toolModeString;
|
||||
switch (tool->toolMode()) {
|
||||
case IAnalyzerTool::DebugMode:
|
||||
toolModeString = AnalyzerManager::tr("Debug");
|
||||
break;
|
||||
case IAnalyzerTool::ReleaseMode:
|
||||
toolModeString = AnalyzerManager::tr("Release");
|
||||
break;
|
||||
default:
|
||||
QTC_CHECK(false);
|
||||
}
|
||||
const QString toolName = tool->displayName();
|
||||
const QString title = AnalyzerManager::tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode);
|
||||
const QString message = AnalyzerManager::tr("<html><head/><body><p>You are trying "
|
||||
"to run the tool \"%1\" on an application in %2 mode. "
|
||||
"The tool is designed to be used in %3 mode.</p><p>"
|
||||
"Debug and Release mode run-time characteristics differ "
|
||||
"significantly, analytical findings for one mode may or "
|
||||
"may not be relevant for the other.</p><p>"
|
||||
"Do you want to continue and run the tool in %2 mode?</p></body></html>")
|
||||
.arg(toolName).arg(currentMode).arg(toolModeString);
|
||||
const QString checkBoxText = AnalyzerManager::tr("&Do not ask again");
|
||||
bool checkBoxSetting = false;
|
||||
const QDialogButtonBox::StandardButton button =
|
||||
Utils::CheckableMessageBox::question(ICore::mainWindow(),
|
||||
title, message, checkBoxText,
|
||||
&checkBoxSetting, QDialogButtonBox::Yes|QDialogButtonBox::Cancel,
|
||||
QDialogButtonBox::Cancel);
|
||||
ret = button == QDialogButtonBox::Yes ? QDialog::Accepted : QDialog::Rejected;
|
||||
|
||||
if (checkBoxSetting && ret == QDialog::Accepted)
|
||||
settings->setValue(configKey, ret);
|
||||
}
|
||||
if (ret == QDialog::Rejected)
|
||||
return;
|
||||
}
|
||||
|
||||
pe->runProject(pro, tool->runMode());
|
||||
}
|
||||
|
||||
static void startRemoteTool(IAnalyzerTool *tool)
|
||||
{
|
||||
StartRemoteDialog dlg;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
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();
|
||||
|
||||
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
|
||||
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
|
||||
|
||||
ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode());
|
||||
}
|
||||
|
||||
void IAnalyzerTool::startTool(StartMode mode)
|
||||
{
|
||||
if (mode == StartLocal)
|
||||
startLocalTool(this);
|
||||
if (mode == StartRemote)
|
||||
startRemoteTool(this);
|
||||
}
|
||||
|
||||
} // namespace Analyzer
|
||||
|
@@ -112,7 +112,7 @@ public:
|
||||
virtual AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0) = 0;
|
||||
|
||||
virtual void startTool(StartMode mode) = 0;
|
||||
virtual void startTool(StartMode mode);
|
||||
|
||||
/// Called when tools gets selected.
|
||||
virtual void toolSelected() const {}
|
||||
|
@@ -612,7 +612,7 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa
|
||||
|
||||
void CallgrindTool::startTool(StartMode mode)
|
||||
{
|
||||
ValgrindPlugin::startValgrindTool(this, mode);
|
||||
IAnalyzerTool::startTool(mode);
|
||||
d->setBusyCursor(true);
|
||||
}
|
||||
|
||||
|
@@ -464,11 +464,6 @@ AnalyzerRunControl *MemcheckTool::createRunControl(const AnalyzerStartParameters
|
||||
return engine;
|
||||
}
|
||||
|
||||
void MemcheckTool::startTool(StartMode mode)
|
||||
{
|
||||
ValgrindPlugin::startValgrindTool(this, mode);
|
||||
}
|
||||
|
||||
void MemcheckTool::engineStarting(const AnalyzerRunControl *engine)
|
||||
{
|
||||
setBusyCursor(true);
|
||||
|
@@ -113,7 +113,6 @@ private:
|
||||
|
||||
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration = 0);
|
||||
void startTool(Analyzer::StartMode mode);
|
||||
|
||||
void clearErrorView();
|
||||
|
||||
|
@@ -34,62 +34,16 @@
|
||||
#include "memchecktool.h"
|
||||
#include "valgrindruncontrolfactory.h"
|
||||
|
||||
#include <analyzerbase/analyzerconstants.h>
|
||||
#include <analyzerbase/analyzermanager.h>
|
||||
#include <analyzerbase/analyzerrunconfigwidget.h>
|
||||
#include <analyzerbase/analyzerruncontrol.h>
|
||||
#include <analyzerbase/analyzerstartparameters.h>
|
||||
#include <analyzerbase/startremotedialog.h>
|
||||
|
||||
#include <projectexplorer/localapplicationrunconfiguration.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtPlugin>
|
||||
#include <QAction>
|
||||
|
||||
using namespace Analyzer;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
|
||||
namespace Valgrind {
|
||||
namespace Internal {
|
||||
|
||||
static void startRemoteTool(IAnalyzerTool *tool)
|
||||
{
|
||||
Q_UNUSED(tool);
|
||||
StartRemoteDialog dlg;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
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();
|
||||
|
||||
//AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
|
||||
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
|
||||
//m_currentRunControl = rc;
|
||||
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
|
||||
|
||||
ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode());
|
||||
}
|
||||
|
||||
void ValgrindPlugin::startValgrindTool(IAnalyzerTool *tool, StartMode mode)
|
||||
{
|
||||
if (mode == StartLocal)
|
||||
AnalyzerManager::startLocalTool(tool);
|
||||
if (mode == StartRemote)
|
||||
startRemoteTool(tool);
|
||||
}
|
||||
|
||||
bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||
{
|
||||
StartModes modes;
|
||||
|
@@ -47,8 +47,6 @@ public:
|
||||
|
||||
virtual bool initialize(const QStringList &arguments, QString *errorString);
|
||||
virtual void extensionsInitialized() {}
|
||||
|
||||
static void startValgrindTool(Analyzer::IAnalyzerTool *tool, Analyzer::StartMode mode);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user