Sketcher: fix lost of constraint in undo/redo

This commit is contained in:
Zheng, Lei
2019-08-23 19:10:58 +08:00
committed by wmayer
parent eb24c84468
commit 7128cf7989
2 changed files with 14 additions and 7 deletions

View File

@@ -176,6 +176,7 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
// setup and diagnose the sketch
try {
rebuildExternalGeometry();
Constraints.acceptGeometry(getCompleteGeometry());
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\nClear constraints to external geometry\n", e.what());
@@ -912,9 +913,7 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo)
}
this->Geometry.setValues(newVals);
this->Constraints.setValues(newConstraints);
for (Constraint* it : newConstraints)
delete it;
this->Constraints.setValues(std::move(newConstraints));
this->Constraints.acceptGeometry(getCompleteGeometry());
rebuildVertexIndex();
@@ -5357,9 +5356,7 @@ int SketchObject::delExternal(int ExtGeoId)
}
solverNeedsUpdate=true;
Constraints.setValues(newConstraints);
for (Constraint* it : newConstraints)
delete it;
Constraints.setValues(std::move(newConstraints));
Constraints.acceptGeometry(getCompleteGeometry());
rebuildVertexIndex();
return 0;
@@ -5429,7 +5426,7 @@ int SketchObject::delConstraintsToExternal()
}
}
Constraints.setValues(newConstraints);
Constraints.setValues(std::move(newConstraints));
Constraints.acceptGeometry(getCompleteGeometry());
if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver

View File

@@ -4327,6 +4327,16 @@ Restart:
SoSeparator *sep = static_cast<SoSeparator *>(edit->constrGroup->getChild(i));
const Constraint *Constr = *it;
if(Constr->First < -extGeoCount || Constr->First >= intGeoCount
|| (Constr->Second!=Constraint::GeoUndef
&& (Constr->Second < -extGeoCount || Constr->Second >= intGeoCount))
|| (Constr->Third!=Constraint::GeoUndef
&& (Constr->Third < -extGeoCount || Constr->Third >= intGeoCount)))
{
// Constraint can refer to non-existent geometry during undo/redo
continue;
}
// distinquish different constraint types to build up
switch (Constr->Type) {
case Block: