Assembly: Fix #12889 : deleting a part does not delete joint and later crashes freecad.
This commit is contained in:
committed by
Yorik van Havre
parent
ef010e6f7c
commit
5349d08abe
@@ -235,7 +235,7 @@ void AssemblyObject::undoSolve()
|
||||
previousPositions.clear();
|
||||
|
||||
// update joint placements:
|
||||
getJoints();
|
||||
getJoints(/*updateJCS*/ true, /*delBadJoints*/ false);
|
||||
}
|
||||
|
||||
void AssemblyObject::clearUndo()
|
||||
@@ -398,7 +398,7 @@ JointGroup* AssemblyObject::getJointGroup()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> AssemblyObject::getJoints(bool updateJCS)
|
||||
std::vector<App::DocumentObject*> AssemblyObject::getJoints(bool updateJCS, bool delBadJoints)
|
||||
{
|
||||
std::vector<App::DocumentObject*> joints = {};
|
||||
|
||||
@@ -414,7 +414,16 @@ std::vector<App::DocumentObject*> AssemblyObject::getJoints(bool updateJCS)
|
||||
}
|
||||
|
||||
auto* prop = dynamic_cast<App::PropertyBool*>(joint->getPropertyByName("Activated"));
|
||||
if (prop && !prop->getValue()) {
|
||||
if (!prop || !prop->getValue()) {
|
||||
// Filter grounded joints and deactivated joints.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!getLinkObjFromProp(joint, "Part1") || !getLinkObjFromProp(joint, "Part2")) {
|
||||
// Remove incomplete joints. Left-over when the user delets a part.
|
||||
if (delBadJoints) {
|
||||
getDocument()->removeObject(joint->getNameInDocument());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
|
||||
void jointParts(std::vector<App::DocumentObject*> joints);
|
||||
JointGroup* getJointGroup();
|
||||
std::vector<App::DocumentObject*> getJoints(bool updateJCS = true);
|
||||
std::vector<App::DocumentObject*> getJoints(bool updateJCS = true, bool delBadJoints = true);
|
||||
std::vector<App::DocumentObject*> getGroundedJoints();
|
||||
std::vector<App::DocumentObject*> getJointsOfObj(App::DocumentObject* obj);
|
||||
std::vector<App::DocumentObject*> getJointsOfPart(App::DocumentObject* part);
|
||||
|
||||
Reference in New Issue
Block a user