From 24b9cdb4f928d66d5cd3f6ee7ff6c5740936df52 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Thu, 25 Dec 2025 19:14:42 -0300 Subject: [PATCH] PartDesign: fix transform removal causing an invalid base feature on the next solid if it was broken itself --- src/Mod/PartDesign/App/Body.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 4ab0d311b5..8c0782b420 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -337,17 +337,18 @@ void Body::setBaseProperty(App::DocumentObject* feature) std::vector Body::removeObject(App::DocumentObject* feature) { + // This method must be called BEFORE the feature is removed from the Document! + App::DocumentObject* nextSolidFeature = getNextSolidFeature(feature); App::DocumentObject* prevSolidFeature = getPrevSolidFeature(feature); - // This method must be called BEFORE the feature is removed from the Document! - if (isSolidFeature(feature)) { - // This is a solid feature - // If the next feature is solid, reroute its BaseFeature property to the previous solid feature - if (nextSolidFeature) { - assert(nextSolidFeature->isDerivedFrom(PartDesign::Feature::getClassTypeId())); - // Note: It's ok to remove the first solid feature, that just mean the next feature - // become the base one - static_cast(nextSolidFeature)->BaseFeature.setValue(prevSolidFeature); + + // It's ok to remove the first solid feature, that just mean the next feature become the base one + + if (nextSolidFeature && nextSolidFeature->isDerivedFrom(PartDesign::Feature::getClassTypeId())) { + auto* nextPD = static_cast(nextSolidFeature); + // Check if the next feature is pointing to the one being deleted + if (nextPD->BaseFeature.getValue() == feature) { + nextPD->BaseFeature.setValue(prevSolidFeature); } }