[PD] Fix isFeatureMovable() to check null status of property
As reported by @donovaly, if you try to move a pipe that does not have an auxilliary spine, the code segfaults. This commit adds a check to ensure that not only does the property exist (which in this case it always does), but also that it does not contain a null. That is a valid value for the property to have, but cannot be itself interrogated for moveability by the isFeatureMovable recursive call. This fix is also applied to the other similar conditions in that function to ensure they never yield the same segmentation fault. Forums topic: https://forum.freecadweb.org/viewtopic.php?p=479388#p479388
This commit is contained in:
@@ -450,19 +450,19 @@ bool isFeatureMovable(App::DocumentObject* const feat)
|
||||
|
||||
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("ReferenceAxis"))) {
|
||||
App::DocumentObject* axis = prop->getValue();
|
||||
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
|
||||
if (axis && !isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("Spine"))) {
|
||||
App::DocumentObject* axis = prop->getValue();
|
||||
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
|
||||
App::DocumentObject* spine = prop->getValue();
|
||||
if (spine && !isFeatureMovable(static_cast<App::DocumentObject*>(spine)))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto prop = static_cast<App::PropertyLinkSub*>(prim->getPropertyByName("AuxillerySpine"))) {
|
||||
App::DocumentObject* axis = prop->getValue();
|
||||
if (!isFeatureMovable(static_cast<App::DocumentObject*>(axis)))
|
||||
App::DocumentObject* auxSpine = prop->getValue();
|
||||
if (auxSpine && !isFeatureMovable(static_cast<App::DocumentObject*>(auxSpine)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user