Assembly: Fix crash 20614 (#22538)

This commit is contained in:
PaddleStroke
2025-07-18 16:53:35 +02:00
committed by GitHub
parent c2832547f8
commit facfbeb47e
2 changed files with 25 additions and 1 deletions

View File

@@ -1334,7 +1334,7 @@ AssemblyObject::makeMbdJoint(App::DocumentObject* joint)
JointType jointType = getJointType(joint);
std::shared_ptr<ASMTJoint> mbdJoint = makeMbdJointOfType(joint, jointType);
if (!mbdJoint) {
if (!mbdJoint || !isMbDJointValid(joint)) {
return {};
}
@@ -1724,6 +1724,28 @@ int AssemblyObject::slidingPartIndex(App::DocumentObject* joint)
return slidingFound;
}
bool AssemblyObject::isMbDJointValid(App::DocumentObject* joint)
{
// When dragging a part, we are bundling fixed parts together.
// This may lead to a conflicting joint that is self referencing a MbD part.
// The solver crash when fed such a bad joint. So we make sure it does not happen.
App::DocumentObject* part1 = getMovingPartFromRef(this, joint, "Reference1");
App::DocumentObject* part2 = getMovingPartFromRef(this, joint, "Reference2");
if (!part1 || !part2) {
return false;
}
// If this joint is self-referential it must be ignored.
if (getMbDPart(part1) == getMbDPart(part2)) {
Base::Console().warning(
"Assembly: Ignoring joint (%s) because its parts are connected by a fixed "
"joint bundle. This joint is a conflicting or redundant constraint.\n",
joint->getFullLabel());
return false;
}
return true;
}
AssemblyObject::MbDPartData AssemblyObject::getMbDData(App::DocumentObject* part)
{
auto it = objectPartMap.find(part);