From 214169616d0066f52360f1584766174206364d23 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Thu, 25 Jun 2015 13:58:43 +0200 Subject: [PATCH] Sketch: Bug fix: On delete crash with unsuccesful solving ========================================================== Fixes the one reported by JMG here (Thanks!!): http://forum.freecadweb.org/viewtopic.php?f=3&t=11508#p92693 Why? - The newly introduced redrawing policy requires that the solver geometry matches in number the sketchobject geometry. - Most (all) problems with updateColor or getGeometry returning a null pointer are related to an out of sync between UI geometry and SketchObject geometry. General solution: - In other bugs, a missing "solve()" is the problem, once the solver and sketchobject geometries have the same number, an SketchObject::OnChanged triggers a VPSketch::draw (via VPSketch::updateData) which updates the UI geometry to match SketchObject geometry and then the problem does not arise. Particular solution: - In this bug, the problem is not a missing solve, but the fact that the solving was not succesful and did not synchronize the geometries, however triggering a draw() on unsuccessful solving, syncronizes the UI geometry with the SketchObject geometry and the crash is gone. --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 261bf6406..fc4fe91bc 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -4785,10 +4785,18 @@ bool ViewProviderSketch::onDelete(const std::vector &subList) } } - getSketchObject()->solve(); - + int ret=getSketchObject()->solve(); + + if(ret!=0){ + // if the sketched could not be solved, we first redraw to update the UI geometry as + // onChanged did not update it. + UpdateSolverInformation(); + draw(); + } + this->drawConstraintIcons(); this->updateColor(); + // if in edit not delete the object return false; }