Skip to content

Commit

Permalink
Sketcher: fix potential crash on solve due to expression changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
realthunder committed Feb 13, 2021
1 parent 67b3228 commit 6df0e97
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Mod/Sketcher/App/SketchObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6df0e97

Please sign in to comment.