Sketcher: Skip checks in deriveConstraintsForPieces when risky

Possibly fixes #22352.

It is possible to call the method when new geos are not yet created or added to
the sketch. In such cases, the values obtained can be "dirty", and is likely a
seg-fault.
This commit is contained in:
Ajinkya Dahale
2025-07-19 03:07:31 +05:30
parent f468e4c4ac
commit 018ac7b9dd

View File

@@ -3578,6 +3578,8 @@ bool SketchObject::deriveConstraintsForPieces(const int oldId,
conPos = con->SecondPos;
}
bool newGeosLikelyNotCreated = std::ranges::find(newGeos, nullptr) != newGeos.end();
bool transferToAll = false;
switch (con->Type) {
case Horizontal:
@@ -3598,6 +3600,11 @@ bool SketchObject::deriveConstraintsForPieces(const int oldId,
return false;
}
// no use going forward if newGeos aren't ready
if (newGeosLikelyNotCreated) {
break;
}
// For now: just transfer to the first intersection
// TODO: Actually check that there was perpendicularity earlier
// TODO: Choose piece based on parameters ("values" of the constraint)
@@ -3632,10 +3639,11 @@ bool SketchObject::deriveConstraintsForPieces(const int oldId,
return true;
}
if (conId == GeoEnum::GeoUndef) {
if (conId == GeoEnum::GeoUndef || newGeosLikelyNotCreated) {
// nothing further to do
return false;
}
Base::Vector3d conPoint(getPoint(conId, conPos));
double conParam;
auto* geoAsCurve = static_cast<const Part::GeomCurve*>(geo);