PartDesign: Fix crash on editing feature outside of body

This commit is contained in:
Kacper Donat
2025-09-27 16:21:51 +02:00
committed by Chris Hennes
parent 7a266b1d78
commit d712537638

View File

@@ -143,9 +143,16 @@ bool ViewProvider::setEdit(int ModNum)
}
}
previouslyShownViewProvider = dynamic_cast<ViewProvider*>(
Gui::Application::Instance->getViewProvider(getBodyViewProvider()->getShownFeature())
);
// This is handling for an erroneous case where features are for some reason placed outside
// the body container. That should never happen, but in some cases we find models with a
// problem like that.
if (ViewProviderBody* bodyViewProvider = getBodyViewProvider()) {
PartDesign::Feature* shownFeature = bodyViewProvider->getShownFeature();
previouslyShownViewProvider = freecad_cast<ViewProvider*>(
Gui::Application::Instance->getViewProvider(shownFeature)
);
}
// clear the selection (convenience)
Gui::Selection().clearSelection();