Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing property Object1 or Object2 of fixed joint causing crash #13912

Merged
6 changes: 3 additions & 3 deletions src/Mod/Assembly/App/AssemblyObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
{
Base::Vector3d pos = plc.getPosition();
Base::Vector3d axis;
double angle;

Check warning on line 95 in src/Mod/Assembly/App/AssemblyObject.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'angle' is not initialized [cppcoreguidelines-init-variables]
Base::Rotation rot = plc.getRotation();
rot.getRawValue(axis, angle);
Base::Console().Warning(
Expand All @@ -109,7 +109,7 @@

// ================================ Assembly Object ============================

PROPERTY_SOURCE(Assembly::AssemblyObject, App::Part)

Check warning on line 112 in src/Mod/Assembly/App/AssemblyObject.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'classTypeId' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

Check warning on line 112 in src/Mod/Assembly/App/AssemblyObject.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'propertyData' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

AssemblyObject::AssemblyObject()
: mbdAssembly(std::make_shared<ASMTAssembly>())
Expand Down Expand Up @@ -146,7 +146,7 @@
std::vector<App::DocumentObject*> groundedObjs = fixGroundedParts();
if (groundedObjs.empty()) {
// If no part fixed we can't solve.
return -6;

Check warning on line 149 in src/Mod/Assembly/App/AssemblyObject.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
}

std::vector<App::DocumentObject*> joints = getJoints(updateJCS);
Expand Down Expand Up @@ -174,7 +174,7 @@
return 0;
}

void AssemblyObject::preDrag(std::vector<App::DocumentObject*> dragParts)

Check warning on line 177 in src/Mod/Assembly/App/AssemblyObject.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

the parameter 'dragParts' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
{
solve();

Expand Down Expand Up @@ -257,7 +257,7 @@

void AssemblyObject::undoSolve()
{
if (previousPositions.size() == 0) {

Check warning on line 260 in src/Mod/Assembly/App/AssemblyObject.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
return;
}

Expand Down Expand Up @@ -484,7 +484,7 @@
auto* part1 = getLinkObjFromProp(joint, "Part1");
auto* part2 = getLinkObjFromProp(joint, "Part2");
if (!part1 || !part2 || part1->getFullName() == part2->getFullName()) {
// Remove incomplete joints. Left-over when the user delets a part.

Check warning on line 487 in src/Mod/Assembly/App/AssemblyObject.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

delets ==> deletes
// Remove incoherent joints (self-pointing joints)
if (delBadJoints) {
getDocument()->removeObject(joint->getNameInDocument());
Expand Down Expand Up @@ -1166,9 +1166,9 @@
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 "";
}
Expand Down