From d2e420bfe725d79278a2c22415e5c4682bab77b2 Mon Sep 17 00:00:00 2001 From: Aaron Barany Date: Wed, 23 Jan 2019 22:41:58 -0800 Subject: [PATCH] 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 --- src/plugins/cmakeprojectmanager/cmakebuildstep.cpp | 4 +++- src/plugins/cmakeprojectmanager/cmakebuildstep.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 21556ce0fd2..f319af05d49 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -115,8 +115,10 @@ CMakeRunConfiguration *CMakeBuildStep::targetsActiveRunConfiguration() const return qobject_cast(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(project())->buildTargetTitles().contains(m_buildTarget)) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.h b/src/plugins/cmakeprojectmanager/cmakebuildstep.h index cfae9c9aabe..91dab9b455d 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.h @@ -101,7 +101,7 @@ private: void runImpl(QFutureInterface &fi); void handleProjectWasParsed(QFutureInterface &fi, bool success); - void handleBuildTargetChanges(); + void handleBuildTargetChanges(bool success); CMakeRunConfiguration *targetsActiveRunConfiguration() const; QMetaObject::Connection m_runTrigger;