PartDesign: fix transform removal causing an invalid base feature on the next solid if it was broken itself

This commit is contained in:
Alfredo Monclus
2025-12-25 19:14:42 -03:00
committed by Kacper Donat
parent ee7d84bb03
commit 24b9cdb4f9

View File

@@ -337,17 +337,18 @@ void Body::setBaseProperty(App::DocumentObject* feature)
std::vector<App::DocumentObject*> 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<PartDesign::Feature*>(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<PartDesign::Feature*>(nextSolidFeature);
// Check if the next feature is pointing to the one being deleted
if (nextPD->BaseFeature.getValue() == feature) {
nextPD->BaseFeature.setValue(prevSolidFeature);
}
}