forked from qt-creator/qt-creator
ProjectExplorer: Consolidate some Session::active* accesses
Change-Id: I47b0f6c2c60b2f7c86b6ffd1ad3df393d1321c8b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -65,16 +65,17 @@ static void addProjectPanelWidget()
|
||||
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
||||
}
|
||||
|
||||
void ClangCodeModelPlugin::generateCompilationDB() {
|
||||
void ClangCodeModelPlugin::generateCompilationDB()
|
||||
{
|
||||
using namespace CppTools;
|
||||
|
||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
||||
if (!project || !project->activeTarget())
|
||||
ProjectExplorer::Target *target = ProjectExplorer::SessionManager::startupTarget();
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
QFuture<Utils::GenerateCompilationDbResult> task
|
||||
= QtConcurrent::run(&Utils::generateCompilationDB,
|
||||
CppModelManager::instance()->projectInfo(project));
|
||||
CppModelManager::instance()->projectInfo(target->project()));
|
||||
Core::ProgressManager::addTask(task, tr("Generating Compilation DB"), "generate compilation db");
|
||||
m_generatorWatcher.setFuture(task);
|
||||
}
|
||||
|
@@ -1433,7 +1433,7 @@ void DebuggerPluginPrivate::updatePresetState()
|
||||
return;
|
||||
|
||||
Project *startupProject = SessionManager::startupProject();
|
||||
RunConfiguration *startupRunConfig = RunConfiguration::startupRunConfiguration();
|
||||
RunConfiguration *startupRunConfig = SessionManager::startupRunConfiguration();
|
||||
DebuggerEngine *currentEngine = EngineManager::currentEngine();
|
||||
|
||||
QString whyNot;
|
||||
@@ -2199,7 +2199,7 @@ static bool buildTypeAccepted(QFlags<ToolMode> toolMode, BuildConfiguration::Bui
|
||||
static BuildConfiguration::BuildType startupBuildType()
|
||||
{
|
||||
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
|
||||
if (RunConfiguration *runConfig = RunConfiguration::startupRunConfiguration()) {
|
||||
if (RunConfiguration *runConfig = SessionManager::startupRunConfiguration()) {
|
||||
if (const BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration())
|
||||
buildType = buildConfig->buildType();
|
||||
}
|
||||
@@ -2375,9 +2375,7 @@ void DebuggerUnitTests::testStateMachine()
|
||||
|
||||
ExecuteOnDestruction guard([] { EditorManager::closeAllEditors(false); });
|
||||
|
||||
Target *t = SessionManager::startupProject()->activeTarget();
|
||||
QVERIFY(t);
|
||||
RunConfiguration *rc = t->activeRunConfiguration();
|
||||
RunConfiguration *rc = SessionManager::startupRunConfiguration();
|
||||
QVERIFY(rc);
|
||||
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
|
@@ -96,11 +96,7 @@ void PerfLoadDialog::on_browseExecutableDirButton_pressed()
|
||||
|
||||
void PerfLoadDialog::chooseDefaults()
|
||||
{
|
||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
||||
if (!project)
|
||||
return;
|
||||
|
||||
ProjectExplorer::Target *target = project->activeTarget();
|
||||
ProjectExplorer::Target *target = ProjectExplorer::SessionManager::startupTarget();
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
|
@@ -231,13 +231,11 @@ void PerfProfilerTool::createViews()
|
||||
connect(recordMenu, &QMenu::aboutToShow, recordMenu, [recordMenu] {
|
||||
recordMenu->hide();
|
||||
PerfSettings *settings = nullptr;
|
||||
Target *target = nullptr;
|
||||
if (auto project = ProjectExplorer::SessionManager::startupProject()) {
|
||||
if ((target = project->activeTarget())) {
|
||||
Target *target = SessionManager::startupTarget();
|
||||
if (target) {
|
||||
if (auto runConfig = target->activeRunConfiguration())
|
||||
settings = runConfig->currentSettings<PerfSettings>(Constants::PerfSettingsId);
|
||||
}
|
||||
}
|
||||
|
||||
PerfConfigWidget *widget = new PerfConfigWidget(
|
||||
settings ? settings : PerfProfilerPlugin::globalSettings(),
|
||||
|
@@ -51,8 +51,7 @@ PerfTracePointDialog::PerfTracePointDialog() :
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (Project *currentProject = SessionManager::startupProject()) {
|
||||
if (const Target *target = currentProject->activeTarget()) {
|
||||
if (const Target *target = SessionManager::startupTarget()) {
|
||||
const Kit *kit = target->kit();
|
||||
QTC_ASSERT(kit, return);
|
||||
|
||||
@@ -62,7 +61,6 @@ PerfTracePointDialog::PerfTracePointDialog() :
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_device) {
|
||||
const DeviceManager *deviceManager = DeviceManager::instance();
|
||||
|
@@ -112,8 +112,7 @@ void KitChooser::populate()
|
||||
const Id lastKit = Id::fromSetting(ICore::settings()->value(lastKitKey));
|
||||
bool didActivate = false;
|
||||
|
||||
if (Project *project = SessionManager::startupProject()) {
|
||||
if (Target *target = project->activeTarget()) {
|
||||
if (Target *target = SessionManager::startupTarget()) {
|
||||
Kit *kit = target->kit();
|
||||
if (m_kitPredicate(kit)) {
|
||||
QString display = tr("Kit of Active Project: %1").arg(kitText(kit));
|
||||
@@ -127,7 +126,6 @@ void KitChooser::populate()
|
||||
m_hasStartupKit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Kit *kit, KitManager::sortKits(KitManager::kits())) {
|
||||
if (m_kitPredicate(kit)) {
|
||||
|
@@ -2962,12 +2962,13 @@ void ProjectExplorerPluginPrivate::activeRunConfigurationChanged()
|
||||
void ProjectExplorerPluginPrivate::activeBuildConfigurationChanged()
|
||||
{
|
||||
static QPointer<BuildConfiguration> previousBuildConfiguration = nullptr;
|
||||
|
||||
BuildConfiguration *bc = nullptr;
|
||||
Project *startupProject = SessionManager::startupProject();
|
||||
if (startupProject && startupProject->activeTarget())
|
||||
bc = startupProject->activeTarget()->activeBuildConfiguration();
|
||||
if (Target *target = SessionManager::startupTarget())
|
||||
bc = target->activeBuildConfiguration();
|
||||
if (bc == previousBuildConfiguration)
|
||||
return;
|
||||
|
||||
updateActions();
|
||||
emit m_instance->updateRunActions();
|
||||
}
|
||||
|
@@ -265,20 +265,6 @@ void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory)
|
||||
theAspectFactories.push_back(aspectFactory);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the RunConfiguration of the currently active target
|
||||
* of the startup project, if such exists, or \c nullptr otherwise.
|
||||
*/
|
||||
|
||||
RunConfiguration *RunConfiguration::startupRunConfiguration()
|
||||
{
|
||||
if (Project *pro = SessionManager::startupProject()) {
|
||||
if (const Target *target = pro->activeTarget())
|
||||
return target->activeRunConfiguration();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QMap<Core::Id, QVariantMap> RunConfiguration::aspectData() const
|
||||
{
|
||||
QMap<Core::Id, QVariantMap> data;
|
||||
|
@@ -155,8 +155,6 @@ public:
|
||||
// The BuildTargetInfo corresponding to the buildKey.
|
||||
BuildTargetInfo buildTargetInfo() const;
|
||||
|
||||
static RunConfiguration *startupRunConfiguration();
|
||||
|
||||
template <class T = ISettingsAspect> T *currentSettings(Core::Id id) const
|
||||
{
|
||||
if (auto a = qobject_cast<GlobalOrProjectAspect *>(aspect(id)))
|
||||
|
@@ -392,6 +392,18 @@ BuildSystem *SessionManager::startupBuildSystem()
|
||||
return t ? t->buildSystem() : nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the RunConfiguration of the currently active target
|
||||
* of the startup project, if such exists, or \c nullptr otherwise.
|
||||
*/
|
||||
|
||||
|
||||
RunConfiguration *SessionManager::startupRunConfiguration()
|
||||
{
|
||||
Target *t = startupTarget();
|
||||
return t ? t->activeRunConfiguration() : nullptr;
|
||||
}
|
||||
|
||||
void SessionManager::addProject(Project *pro)
|
||||
{
|
||||
QTC_ASSERT(pro, return);
|
||||
|
@@ -44,6 +44,7 @@ class Target;
|
||||
class BuildConfiguration;
|
||||
class BuildSystem;
|
||||
class DeployConfiguration;
|
||||
class RunConfiguration;
|
||||
|
||||
enum class SetActive { Cascade, NoCascade };
|
||||
|
||||
@@ -100,6 +101,7 @@ public:
|
||||
static Project *startupProject();
|
||||
static Target *startupTarget();
|
||||
static BuildSystem *startupBuildSystem();
|
||||
static RunConfiguration *startupRunConfiguration();
|
||||
|
||||
static const QList<Project *> projects();
|
||||
static bool hasProjects();
|
||||
|
@@ -139,10 +139,8 @@ Target::Target(Project *project, Kit *k, _constructor_tag) :
|
||||
});
|
||||
|
||||
connect(this, &Target::parsingFinished, this, [this, project](bool success) {
|
||||
if (success && project == SessionManager::startupProject()
|
||||
&& this == project->activeTarget()) {
|
||||
if (success && this == SessionManager::startupTarget())
|
||||
updateDefaultRunConfigurations();
|
||||
}
|
||||
// For testing.
|
||||
emit SessionManager::instance()->projectFinishedParsing(project);
|
||||
project->anyParsingFinished(this, success);
|
||||
|
@@ -558,7 +558,7 @@ ProjectExplorer::RunControl *QmlProfilerTool::attachToWaitingApplication()
|
||||
d->m_viewContainer->perspective()->select();
|
||||
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setRunConfiguration(RunConfiguration::startupRunConfiguration());
|
||||
runControl->setRunConfiguration(SessionManager::startupRunConfiguration());
|
||||
auto profiler = new QmlProfilerRunner(runControl);
|
||||
profiler->setServerUrl(serverUrl);
|
||||
|
||||
|
@@ -46,6 +46,7 @@
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
@@ -238,7 +239,7 @@ void QnxAttachDebugSupport::showProcessesDialog()
|
||||
return;
|
||||
|
||||
// FIXME: That should be somehow related to the selected kit.
|
||||
auto startRunConfig = RunConfiguration::startupRunConfiguration();
|
||||
auto startRunConfig = SessionManager::startupRunConfiguration();
|
||||
auto runConfig = qobject_cast<QnxRunConfiguration *>(startRunConfig);
|
||||
if (!runConfig)
|
||||
return;
|
||||
|
@@ -276,7 +276,7 @@ CallgrindToolPrivate::CallgrindToolPrivate()
|
||||
menu->addAction(ActionManager::registerAction(action, CallgrindRemoteActionId),
|
||||
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
QObject::connect(action, &QAction::triggered, this, [this, action] {
|
||||
auto runConfig = RunConfiguration::startupRunConfiguration();
|
||||
auto runConfig = SessionManager::startupRunConfiguration();
|
||||
if (!runConfig) {
|
||||
showCannotStartDialog(action->text());
|
||||
return;
|
||||
|
@@ -676,7 +676,7 @@ MemcheckToolPrivate::MemcheckToolPrivate()
|
||||
menu->addAction(ActionManager::registerAction(action, "Memcheck.Remote"),
|
||||
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
QObject::connect(action, &QAction::triggered, this, [this, action] {
|
||||
auto runConfig = RunConfiguration::startupRunConfiguration();
|
||||
RunConfiguration *runConfig = SessionManager::startupRunConfiguration();
|
||||
if (!runConfig) {
|
||||
showCannotStartDialog(action->text());
|
||||
return;
|
||||
|
Reference in New Issue
Block a user