From 5279bf68c78ccfba113ba5bcfb0529f562eb2912 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 9 Jan 2022 11:34:28 +0100 Subject: [PATCH] Sketcher: EditCoinManager - Check constraint types on updating constraint color =============================================================================== Problem: - While SketchObject inhibits intermediate updates during internal command execution, sometimes a change in the selection (clear selection) in an intermediary step triggers an spurious update colour. - There will be a final draw and this update colours at the end of the internal command. - If the types of the constraints changed during the intermediary steps, it may happen that the constraint coin nodes at a given position no longer correspond to the constraint type in the SketchObject property. This may cause a attempt to access to a non-existing node or static casting a existing node to the wrong type. Solution: - Check the type of the constraint against the cached type. If not matching, cancel the color update. --- src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp index 2c24a81657..b91e35e8c0 100644 --- a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp +++ b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp @@ -1266,6 +1266,12 @@ void EditModeConstraintCoinManager::updateConstraintColor(const std::vectorType; + + // It may happen that color updates are triggered by programatic selection changes before a command final update. Then + // constraints may have been changed and the color will be updated as part + if (type != vConstrType[i]) + break; + bool hasDatumLabel = (type == Sketcher::Angle || type == Sketcher::Radius || type == Sketcher::Diameter ||