From 4607ec52f56b7e7a299d05dfd49659d864cab5c1 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 4 Feb 2025 11:05:48 +0100 Subject: [PATCH] CMake: Fix crash when opening project The CMakeBuildStep can be part of a deploy configuration, and then the buildConfiguration() relies on the "active" build configuration. That can be nullptr under some conditions, e.g. we got crash reports for loading projects, where ProjectExplorer::Target::addConfigurationsFromMap might either not restore any build configuration for some reason, or not set an "active" one. Restoring the deploy configurations in that same method afterwards, then leads a call to baseEnvironment() of the deploy step (=CMakeBuildStep) and a crash. Change-Id: I763d9fdbc7a6055eac384e4c5040c3f7b245d3cb Reviewed-by: Christian Kandeler --- src/plugins/cmakeprojectmanager/cmakebuildstep.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 670fa49531d..968a39207a2 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -781,7 +781,8 @@ Environment CMakeBuildStep::baseEnvironment() const ProjectExplorer::IDevice::ConstPtr devicePtr = BuildDeviceKitAspect::device(kit()); result = devicePtr ? devicePtr->systemEnvironment() : Environment::systemEnvironment(); } - buildConfiguration()->addToEnvironment(result); + if (buildConfiguration()) + buildConfiguration()->addToEnvironment(result); kit()->addToBuildEnvironment(result); result.modify(project()->additionalEnvironment()); return result;