forked from qt-creator/qt-creator
Add runConfiguration to remote tool starters
Most of them need a run configuration. It's better to pass the right one than to use various hacky ways to work around it. Change-Id: Ic21b0ef33bdd79b526b1e1a1ead5ca87d9f32c4d Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -89,23 +89,25 @@ void AnalyzerAction::startTool()
|
||||
if (m_toolPreparer && !m_toolPreparer())
|
||||
return;
|
||||
|
||||
// Custom start.
|
||||
if (m_customToolStarter) {
|
||||
m_customToolStarter();
|
||||
return;
|
||||
}
|
||||
|
||||
// ### not sure if we're supposed to check if the RunConFiguration isEnabled
|
||||
Project *pro = SessionManager::startupProject();
|
||||
RunConfiguration *rc = 0;
|
||||
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();
|
||||
rc = target->activeRunConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
// Custom start.
|
||||
if (m_customToolStarter) {
|
||||
m_customToolStarter(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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(m_toolMode, buildType)) {
|
||||
|
@@ -110,7 +110,7 @@ public:
|
||||
void startTool();
|
||||
|
||||
/// This is only used for setups not using the startup project.
|
||||
typedef std::function<void()> ToolStarter;
|
||||
typedef std::function<void(ProjectExplorer::RunConfiguration *runConfiguration)> ToolStarter;
|
||||
void setCustomToolStarter(const ToolStarter &toolStarter) { m_customToolStarter = toolStarter; }
|
||||
|
||||
protected:
|
||||
|
@@ -141,7 +141,9 @@ bool ClangStaticAnalyzerPlugin::initialize(const QStringList &arguments, QString
|
||||
action->setActionId("ClangStaticAnalyzer");
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setCustomToolStarter([tool] { tool->startTool(); });
|
||||
action->setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) {
|
||||
tool->startTool(rc);
|
||||
});
|
||||
action->setText(tr("Clang Static Analyzer"));
|
||||
action->setToolTip(toolTip);
|
||||
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
||||
|
@@ -58,22 +58,6 @@ using namespace ProjectExplorer;
|
||||
namespace ClangStaticAnalyzer {
|
||||
namespace Internal {
|
||||
|
||||
class DummyRunConfiguration : public RunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DummyRunConfiguration(Target *parent)
|
||||
: RunConfiguration(parent, "ClangStaticAnalyzer.DummyRunConfig")
|
||||
{
|
||||
setDefaultDisplayName(tr("Clang Static Analyzer"));
|
||||
addExtraAspects();
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *createConfigurationWidget() override { return 0; }
|
||||
};
|
||||
|
||||
ClangStaticAnalyzerTool::ClangStaticAnalyzerTool(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_diagnosticModel(0)
|
||||
@@ -225,7 +209,7 @@ static bool dontStartAfterHintForDebugMode(Project *project)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClangStaticAnalyzerTool::startTool()
|
||||
void ClangStaticAnalyzerTool::startTool(ProjectExplorer::RunConfiguration *runConfiguration)
|
||||
{
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
@@ -243,21 +227,8 @@ void ClangStaticAnalyzerTool::startTool()
|
||||
m_running = true;
|
||||
handleStateUpdate();
|
||||
|
||||
Target * const target = project->activeTarget();
|
||||
QTC_ASSERT(target, return);
|
||||
DummyRunConfiguration *& rc = m_runConfigs[target];
|
||||
if (!rc) {
|
||||
rc = new DummyRunConfiguration(target);
|
||||
connect(project, &Project::aboutToRemoveTarget, this,
|
||||
[this](Target *t) { m_runConfigs.remove(t); });
|
||||
const auto onProjectRemoved = [this](Project *p) {
|
||||
foreach (Target * const t, p->targets())
|
||||
m_runConfigs.remove(t);
|
||||
};
|
||||
connect(SessionManager::instance(), &SessionManager::aboutToRemoveProject, this,
|
||||
onProjectRemoved, Qt::UniqueConnection);
|
||||
}
|
||||
ProjectExplorerPlugin::runRunConfiguration(rc, Constants::CLANGSTATICANALYZER_RUN_MODE);
|
||||
ProjectExplorerPlugin::runRunConfiguration(runConfiguration,
|
||||
Constants::CLANGSTATICANALYZER_RUN_MODE);
|
||||
}
|
||||
|
||||
CppTools::ProjectInfo ClangStaticAnalyzerTool::projectInfoBeforeBuild() const
|
||||
@@ -328,5 +299,3 @@ void ClangStaticAnalyzerTool::handleStateUpdate()
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangStaticAnalyzer
|
||||
|
||||
#include "clangstaticanalyzertool.moc"
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
QWidget *createWidgets();
|
||||
Analyzer::AnalyzerRunControl *createRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
|
||||
Core::Id runMode);
|
||||
void startTool();
|
||||
void startTool(ProjectExplorer::RunConfiguration *rc);
|
||||
|
||||
signals:
|
||||
void finished(bool success); // For testing.
|
||||
@@ -83,7 +83,6 @@ private:
|
||||
|
||||
QAction *m_goBack;
|
||||
QAction *m_goNext;
|
||||
QHash<ProjectExplorer::Target *, DummyRunConfiguration *> m_runConfigs;
|
||||
bool m_running;
|
||||
};
|
||||
|
||||
|
@@ -81,7 +81,9 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
action->setToolId(Constants::QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setCustomToolStarter([tool] { tool->startRemoteTool(); });
|
||||
action->setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) {
|
||||
tool->startRemoteTool(rc);
|
||||
});
|
||||
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
action->setText(tr("QML Profiler (External)"));
|
||||
|
@@ -487,7 +487,7 @@ bool QmlProfilerTool::prepareTool()
|
||||
return true;
|
||||
}
|
||||
|
||||
void QmlProfilerTool::startRemoteTool()
|
||||
void QmlProfilerTool::startRemoteTool(ProjectExplorer::RunConfiguration *rc)
|
||||
{
|
||||
AnalyzerManager::showMode();
|
||||
|
||||
@@ -525,7 +525,7 @@ void QmlProfilerTool::startRemoteTool()
|
||||
}
|
||||
connection.analyzerPort = port;
|
||||
|
||||
auto runControl = qobject_cast<QmlProfilerRunControl *>(createRunControl(0));
|
||||
auto runControl = qobject_cast<QmlProfilerRunControl *>(createRunControl(rc));
|
||||
runControl->setConnection(connection);
|
||||
|
||||
ProjectExplorerPlugin::startRunControl(runControl, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
|
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
QWidget *createWidgets();
|
||||
bool prepareTool();
|
||||
void startRemoteTool();
|
||||
void startRemoteTool(ProjectExplorer::RunConfiguration *rc);
|
||||
|
||||
static QList <QAction *> profilerContextMenuActions();
|
||||
|
||||
|
@@ -187,11 +187,11 @@ void ValgrindPlugin::extensionsInitialized()
|
||||
action->setActionId("Memcheck.Remote");
|
||||
action->setToolId("Memcheck");
|
||||
action->setWidgetCreator(mcWidgetCreator);
|
||||
action->setCustomToolStarter([mcTool] {
|
||||
action->setCustomToolStarter([mcTool](ProjectExplorer::RunConfiguration *runConfig) {
|
||||
StartRemoteDialog dlg;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return;
|
||||
ValgrindRunControl *rc = mcTool->createRunControl(0, MEMCHECK_RUN_MODE);
|
||||
ValgrindRunControl *rc = mcTool->createRunControl(runConfig, MEMCHECK_RUN_MODE);
|
||||
QTC_ASSERT(rc, return);
|
||||
AnalyzerRunnable runnable;
|
||||
runnable.debuggee = dlg.executable();
|
||||
@@ -214,11 +214,11 @@ void ValgrindPlugin::extensionsInitialized()
|
||||
action->setActionId(CallgrindRemoteActionId);
|
||||
action->setToolId(CallgrindToolId);
|
||||
action->setWidgetCreator(cgWidgetCreator);
|
||||
action->setCustomToolStarter([cgTool] {
|
||||
action->setCustomToolStarter([cgTool](ProjectExplorer::RunConfiguration *runConfig) {
|
||||
StartRemoteDialog dlg;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return;
|
||||
ValgrindRunControl *rc = cgTool->createRunControl(0);
|
||||
ValgrindRunControl *rc = cgTool->createRunControl(runConfig);
|
||||
QTC_ASSERT(rc, return);
|
||||
AnalyzerRunnable runnable;
|
||||
runnable.debuggee = dlg.executable();
|
||||
|
Reference in New Issue
Block a user