Missing property Object1 or Object2 of fixed joint causing crash (#13912)
* Assembly: removal of object of fixed joint causing crash
FreeCAD is crashing if the 'Object'
property of fixed joint (Assembly/Joints/Fixed/Joint Connector 1/Object1 or
Assembly/Joints/Fixed/Joint Connector 2/Object2) is manually removed.
Steps to reproduce:
- make simple Assembly e.g. of two cubes with Fixed joint
- Select Fixed joint in the tree and go-to property 'Data' tab
- Select 'Object1' or 'Object2' of the 'Joint Connector 1' or 'Joint Connector 2'
and remove this reference
- click by your pointing device (mouse) to the arbitrary other property
The FreeCAD will crash here because the call
App::DocumentObject* obj = getObjFromNameProp(joint, propObjName, propPartName);
will return NULL pointer.
This problem is similar to the
8d5348ad066aa216c387582bfdcf066966a4fe09.
* Assembly: fixed warning message text
The warning message text is not describing two cases which can happen,
but only one - property of specific joint.
* Assembly: avoiding possible crash in rack pinion joint code
Similar problems:
07c6df61f8456a6b02e88b369dcef5643ac1574e
and
8d5348ad066aa216c387582bfdcf066966a4fe09
were causing real crashes (Linux + Sway Wayland compositor) when
Fixed joint type was used.
This patch tries to avoid the same situation, but now for the
rack pinion joint type.
The returned pointer value (part1 and obj1) can get NULL pointer value
and is used in the code:
if (obj1->getNameInDocument() != part1->getNameInDocument()) { ....
a few lines later.
This commit is contained in:
@@ -1166,9 +1166,9 @@ std::string AssemblyObject::handleOneSideOfJoint(App::DocumentObject* joint,
|
||||
App::DocumentObject* part = getLinkObjFromProp(joint, propPartName);
|
||||
App::DocumentObject* obj = getObjFromNameProp(joint, propObjName, propPartName);
|
||||
|
||||
if (!part) {
|
||||
Base::Console().Warning("The property %s or Joint %s is empty.",
|
||||
propPartName,
|
||||
if (!part || !obj) {
|
||||
Base::Console().Warning("The property %s of Joint %s is empty.",
|
||||
obj ? propPartName : propObjName,
|
||||
joint->getFullName());
|
||||
return "";
|
||||
}
|
||||
@@ -1223,6 +1223,13 @@ void AssemblyObject::getRackPinionMarkers(App::DocumentObject* joint,
|
||||
App::DocumentObject* obj2 = getObjFromNameProp(joint, "Object2", "Part2");
|
||||
Base::Placement plc2 = getPlacementFromProp(joint, "Placement2");
|
||||
|
||||
if (!part1 || !obj1) {
|
||||
Base::Console().Warning("The property %s of Joint %s is empty.",
|
||||
obj1 ? "Part1" : "Object1",
|
||||
joint->getFullName());
|
||||
return;
|
||||
}
|
||||
|
||||
// For the pinion nothing special needed :
|
||||
markerNameJ = handleOneSideOfJoint(joint, "Object2", "Part2", "Placement2");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user