+ fixes #0001131: Crash when trying to edit sketch

This commit is contained in:
wmayer 2014-03-10 17:16:47 +01:00
parent ea9bc3a9f9
commit b9f284cb42

View File

@ -98,7 +98,15 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
} }
// setup and diagnose the sketch // setup and diagnose the sketch
rebuildExternalGeometry(); try {
rebuildExternalGeometry();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\nClear constraints to external geometry\n", e.what());
// we cannot trust the constraints of external geometries, so remove them
delConstraintsToExternal();
}
Sketch sketch; Sketch sketch;
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(), int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
getExternalGeometryCount()); getExternalGeometryCount());
@ -1185,22 +1193,13 @@ int SketchObject::delConstraintsToExternal()
for (std::vector<Constraint *>::const_iterator it = constraints.begin(); for (std::vector<Constraint *>::const_iterator it = constraints.begin();
it != constraints.end(); ++it) { it != constraints.end(); ++it) {
if ((*it)->First > GeoId && (*it)->Second > GeoId) { if ((*it)->First > GeoId && (*it)->Second > GeoId) {
Constraint *copiedConstr = (*it)->clone(); newConstraints.push_back(*it);
newConstraints.push_back(copiedConstr);
} }
} }
try {
rebuildExternalGeometry();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
return -1;
}
Constraints.setValues(newConstraints); Constraints.setValues(newConstraints);
Constraints.acceptGeometry(getCompleteGeometry()); Constraints.acceptGeometry(getCompleteGeometry());
rebuildVertexIndex();
return 0; return 0;
} }
@ -1585,9 +1584,11 @@ void SketchObject::onChanged(const App::Property* prop)
else if (prop == &Support) { else if (prop == &Support) {
// make sure not to change anything while restoring this object // make sure not to change anything while restoring this object
if (!isRestoring()) { if (!isRestoring()) {
// support face was cleared // if support face was cleared then also clear the external geometry
if (!Support.getValue()) { if (!Support.getValue()) {
delConstraintsToExternal(); std::vector<DocumentObject*> obj;
std::vector<std::string> sub;
ExternalGeometry.setValues(obj, sub);
} }
} }
} }