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