CMake: Don't change targets when parsing fails

When first loading a CMake project, if parsing fails all targets get reset
to the "all" target. Most commonly users will notice this when the "clean"
target gets reset to "all", and can often go unnoticed for a while. This
can become especially annoying when custom target configurations are used.
With this change the previous targets will be preserved upon failure.

Fixes: QTCREATORBUG-21617
Change-Id: I52a3a2c472c7b8d98bc016b1e55a202147fc091c
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Aaron Barany
2019-01-23 22:41:58 -08:00
parent 63ae7eeb1b
commit d2e420bfe7
2 changed files with 4 additions and 2 deletions

View File

@@ -115,8 +115,10 @@ CMakeRunConfiguration *CMakeBuildStep::targetsActiveRunConfiguration() const
return qobject_cast<CMakeRunConfiguration *>(target()->activeRunConfiguration());
}
void CMakeBuildStep::handleBuildTargetChanges()
void CMakeBuildStep::handleBuildTargetChanges(bool success)
{
if (!success)
return; // Do not change when parsing failed.
if (isCurrentExecutableTarget(m_buildTarget))
return; // Do not change just because a different set of build targets is there...
if (!static_cast<CMakeProject *>(project())->buildTargetTitles().contains(m_buildTarget))

View File

@@ -101,7 +101,7 @@ private:
void runImpl(QFutureInterface<bool> &fi);
void handleProjectWasParsed(QFutureInterface<bool> &fi, bool success);
void handleBuildTargetChanges();
void handleBuildTargetChanges(bool success);
CMakeRunConfiguration *targetsActiveRunConfiguration() const;
QMetaObject::Connection m_runTrigger;