diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 64a5fae75793..70f06dff5976 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -6804,7 +6804,12 @@ void SketchObject::onChanged(const App::Property* prop) } } if (prop == &Geometry || prop == &Constraints) { - Constraints.checkGeometry(getCompleteGeometry()); + if(getDocument()->isPerformingTransaction()) { + setStatus(App::PendingTransactionUpdate, true); + } + else { + Constraints.checkGeometry(getCompleteGeometry()); + } } else if (prop == &ExternalGeometry) { // make sure not to change anything while restoring this object @@ -6832,6 +6837,19 @@ void SketchObject::onChanged(const App::Property* prop) Part::Part2DObject::onChanged(prop); } +void SketchObject::onUndoRedoFinished() +{ + // upon undo/redo, PropertyConstraintList does not have updated valid geometry keys, which results in empty constraint lists + // when using getValues + // + // The sketch will also have invalid vertex indices, requiring a call to rebuildVertexIndex + // + // Historically this was "solved" by issuing a recompute, which is absolutely unnecessary and prevents solve() from working before + // such a recompute + acceptGeometry(); + solve(); +} + void SketchObject::onDocumentRestored() { try { diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 7c020441f9e1..57c02b3bcead 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -432,6 +432,8 @@ class SketcherExport SketchObject : public Part::Part2DObject // check whether constraint may be changed driving status int testDrivingChange(int ConstrId, bool isdriving); + virtual void onUndoRedoFinished() override; + private: /// Flag to allow external geometry from other bodies than the one this sketch belongs to bool allowOtherBody;