PD: fix out of scope warnings of Clone feature

If the BaseFeature link of the Body of a Clone feature isn't set then do not update it.
Forum thread: https://forum.freecad.org/viewtopic.php?p=675644#p675644
This commit is contained in:
wmayer
2023-05-14 11:12:49 +02:00
committed by Chris Hennes
parent 6838740153
commit d7c90d3f77
2 changed files with 15 additions and 8 deletions

View File

@@ -73,18 +73,22 @@ App::DocumentObjectExecReturn* FeatureBase::execute() {
return StdReturn;
}
void FeatureBase::trySetBaseFeatureOfBody()
{
if (auto body = getFeatureBody()) {
if (BaseFeature.getValue()
&& body->BaseFeature.getValue()
&& body->BaseFeature.getValue() != BaseFeature.getValue()) {
body->BaseFeature.setValue(BaseFeature.getValue());
}
}
}
void FeatureBase::onChanged(const App::Property* prop) {
// the BaseFeature property should track the Body BaseFeature and vice-versa
if (prop == &BaseFeature) {
auto body = getFeatureBody();
if(!body)
return;
if (BaseFeature.getValue() && body->BaseFeature.getValue() != BaseFeature.getValue()) {
body->BaseFeature.setValue(BaseFeature.getValue());
}
trySetBaseFeatureOfBody();
}
Part::Feature::onChanged(prop);

View File

@@ -48,6 +48,9 @@ public:
void onChanged(const App::Property* prop) override;
App::DocumentObjectExecReturn* execute() override;
void onDocumentRestored() override;
private:
void trySetBaseFeatureOfBody();
};
} //namespace PartDesign