ProjectExplorer: Prevent target switch on project that's to be removed

Switching targets starts up a lot of machinery that is undesired for a
project that's going away.
The same goes for switching build configurations on a target that is
being removed.

Fixes: QTCREATORBUG-25655
Change-Id: I0cb6e395cca8f89bfeb70fcdf571bbcb64f94247
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Christian Kandeler
2021-05-05 11:18:51 +02:00
parent eafba223a5
commit 201786d3fc
19 changed files with 158 additions and 1 deletions

View File

@@ -286,6 +286,9 @@ void SessionManager::setActiveTarget(Project *project, Target *target, SetActive
{
QTC_ASSERT(project, return);
if (project->isShuttingDown())
return;
project->setActiveTarget(target);
if (!target) // never cascade setting no target
@@ -307,6 +310,11 @@ void SessionManager::setActiveTarget(Project *project, Target *target, SetActive
void SessionManager::setActiveBuildConfiguration(Target *target, BuildConfiguration *bc, SetActive cascade)
{
QTC_ASSERT(target, return);
QTC_ASSERT(target->project(), return);
if (target->project()->isShuttingDown() || target->isShuttingDown())
return;
target->setActiveBuildConfiguration(bc);
if (!bc)
@@ -335,6 +343,11 @@ void SessionManager::setActiveBuildConfiguration(Target *target, BuildConfigurat
void SessionManager::setActiveDeployConfiguration(Target *target, DeployConfiguration *dc, SetActive cascade)
{
QTC_ASSERT(target, return);
QTC_ASSERT(target->project(), return);
if (target->project()->isShuttingDown() || target->isShuttingDown())
return;
target->setActiveDeployConfiguration(dc);
if (!dc)
@@ -724,6 +737,7 @@ void SessionManager::removeProjects(const QList<Project *> &remove)
// Delete projects
for (Project *pro : remove) {
pro->saveSettings();
pro->markAsShuttingDown();
// Remove the project node:
d->m_projects.removeOne(pro);