ProjectExplorer: Don't auto-remove manually added run configurations

With this change, if "Create suitable run configurations
automatically" is disabled, we don't remove run configurations, even
if the corresponding target is (currently) missing.

This prevents run configurations that were likely added manually from
being removed automatically. This can be relevant in projects with
cmake arguments that control the targets created in the current
build. Or when switching between branches with different sets of
targets.

One reason to disable "Create suitable run configurations
automatically" may be situations with a large number or targets, where
the user is only interested in a small, manually curated
subset. Automatically removing missing run configurations in this
situation (which is the current behavior without this patch), is
confusing and unexpected.

This is related to the recent change 488624: "ProjectExplorer: Do not
auto-remove customized run configurations", which ensures that run
configurations which have modified settings are not removed
automatically. This is great with "Create suitable run configurations
automatically" enabled, since any missing run configurations would be
added automatically, with their default settings, as soon as they
re-appear as targets. However, if "Create suitable run configurations
automatically" is not enabled, then in general all run-configurations
are added manually, even those that are used with their default
settings. They would have to be manually created over and over again,
if the target frequently disappears and reappears (e.g. due to cmake
setting changes or branch switches). In that case, it is reasonable to
assume that most users don't expect / want their manually added
configurations to be removed automatically.

Fixes: QTCREATORBUG-32289
Change-Id: I6fb93e4e3d6830e7fd4bdb108638ff42e8672c48
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Nikolaus Demmel
2023-05-07 16:34:36 +02:00
parent 94b188c6fc
commit 51c0eb736d

View File

@@ -716,8 +716,11 @@ void Target::updateDefaultRunConfigurations()
present = true; present = true;
} }
} }
if (!present && !rc->isCustomized()) if (!present &&
projectExplorerSettings().automaticallyCreateRunConfigurations &&
!rc->isCustomized()) {
toRemove.append(rc); toRemove.append(rc);
}
} }
configuredCount -= toRemove.count(); configuredCount -= toRemove.count();