[Sketcher] Safeguard against spurious pre-selection
Preselection is sometimes not updated under some circumstances 1. when deleting an object through python; 2. before autoconstraint when deleting previous pole in bspline creation mode. When the preselected curve is the deleted object, segfault/crash can happen.
This commit is contained in:
committed by
abdullahtahiriyo
parent
3fa1735088
commit
f10ccfc0fb
@@ -411,12 +411,15 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
||||
if (preSelPnt != -1)
|
||||
sketchgui->getSketchObject()->getGeoVertexIndex(preSelPnt, GeoId, PosId);
|
||||
else if (preSelCrv != -1){
|
||||
GeoId = preSelCrv;
|
||||
const Part::Geometry *geom = sketchgui->getSketchObject()->getGeometry(GeoId);
|
||||
const Part::Geometry *geom = sketchgui->getSketchObject()->getGeometry(preSelCrv);
|
||||
|
||||
if(geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()){
|
||||
const Part::GeomLineSegment *line = static_cast<const Part::GeomLineSegment *>(geom);
|
||||
hitShapeDir= line->getEndPoint()-line->getStartPoint();
|
||||
// ensure geom exists in case object was called before preselection is updated
|
||||
if (geom) {
|
||||
GeoId = preSelCrv;
|
||||
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
|
||||
const Part::GeomLineSegment *line = static_cast<const Part::GeomLineSegment *>(geom);
|
||||
hitShapeDir= line->getEndPoint()-line->getStartPoint();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -303,7 +303,9 @@ void EditModeGeometryCoinManager::updateGeometryColor(const GeoListFacade & geol
|
||||
}
|
||||
else if (preselectpoint != -1) {
|
||||
preselectpointmfid = coinMapping.getIndexLayer(preselectpoint);
|
||||
if (l == preselectpointmfid.layerId && preselectpointmfid.fieldIndex < PtNum)
|
||||
if (MultiFieldId::Invalid != preselectpointmfid &&
|
||||
preselectpointmfid.layerId == l &&
|
||||
preselectpointmfid.fieldIndex < PtNum)
|
||||
pcolor[preselectpointmfid.fieldIndex] = drawingParameters.PreselectColor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user