From 6df0e976d2f65591f65ff1a68ffa2a6ac58357cc Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Fri, 12 Feb 2021 22:32:21 +0800 Subject: [PATCH] Sketcher: fix potential crash on solve due to expression changes One example of call stacks that may lead to crash is * delGeometires() * delGeometiresExclusiveList(): copy geometries without clone * delConstraintOnPoint() * constraintsRemoved() * touches ExpressionEngine * onChanged() ExpressionEngine * solve() : updates geometry with clone which invalidates the previous copy of geometries This commit will not trigger solve on touch of ExpressionEngine if it is a managed operation Related #103 --- src/Mod/Sketcher/App/SketchObject.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 52b0ed538315..2fca294dba55 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1730,6 +1730,10 @@ int SketchObject::addCopyOfConstraints(const SketchObject &orig) } } + if (noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver + solve(); + + return this->Constraints.getSize()-1; } @@ -6374,6 +6378,10 @@ int SketchObject::carbonCopy(App::DocumentObject * pObj, bool construction) } } + if (noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver + solve(); + + return svals.size(); } @@ -8526,7 +8534,11 @@ void SketchObject::onChanged(const App::Property* prop) } } else if (prop == &ExpressionEngine) { auto doc = getDocument(); - if(!isRestoring() && doc && !doc->isPerformingTransaction() && noRecomputes) { + if(!isRestoring() + && doc && !doc->isPerformingTransaction() + && noRecomputes + && !managedoperation) + { // if we do not have a recompute, the sketch must be solved to // update the DoF of the solver, constraints and UI try {