Skip to content

Commit

Permalink
Sketcher: onUndoRedoFinished implementation and request
Browse files Browse the repository at this point in the history
=======================================================

The sketchobject is now left in a known status after undo/redo transaction
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Jun 14, 2020
1 parent df4a8eb commit 8ef32ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Mod/Sketcher/App/SketchObject.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Sketcher/App/SketchObject.h
Expand Up @@ -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;
Expand Down

0 comments on commit 8ef32ea

Please sign in to comment.