From 0a5f32ff7556d35e64cf7615440d40c3ea9d0907 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 17 Oct 2017 15:41:52 +0200 Subject: [PATCH] CMake: Fix crashes when last target is removed from a project Task-number: QTCREATORBUG-19112 Change-Id: I17893c3e15e9cabc09bf5ebb6746a5d76d9cc0bd Reviewed-by: Eike Ziller --- src/plugins/cmakeprojectmanager/cmakeproject.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 5aac57556ed..24f1ad94281 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -140,6 +140,9 @@ CMakeProject::CMakeProject(const FileName &fileName) : Project(Constants::CMAKEM connect(this, &Project::activeTargetChanged, this, [this]() { CMakeBuildConfiguration *bc = activeBc(this); + if (!bc) + return; + // Target has switched, so the kit has changed, too. // * run cmake with configuration arguments if the reader needs to be switched // * run cmake without configuration arguments if the reader stays @@ -153,6 +156,9 @@ CMakeProject::CMakeProject(const FileName &fileName) : Project(Constants::CMAKEM subscribeSignal(&Target::activeBuildConfigurationChanged, this, [this]() { CMakeBuildConfiguration *bc = activeBc(this); + if (!bc) + return; + // Build configuration has switched: // * Error out if the reader updates, can not happen since all BCs share a target/kit. // * run cmake without configuration arguments if the reader stays