From 62dee011efaeedc1fec3742460203a9adcfa06d3 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 5 Mar 2024 10:19:07 +0100 Subject: [PATCH] Sketcher: fix crash when trying to edit malformed sketch For more details see: https://forum.freecad.org/viewtopic.php?p=745031#p745031 --- src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp index 0af1df62e6..04fc7cdaa8 100644 --- a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp +++ b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp @@ -1749,9 +1749,11 @@ void EditModeConstraintCoinManager::updateConstraintColor( SoMaterial* m = nullptr; if (!hasDatumLabel && type != Sketcher::Coincident && type != Sketcher::InternalAlignment) { - hasMaterial = true; - m = static_cast( - s->getChild(static_cast(ConstraintNodePosition::MaterialIndex))); + int matIndex = static_cast(ConstraintNodePosition::MaterialIndex); + if (matIndex < s->getNumChildren()) { + hasMaterial = true; + m = static_cast(s->getChild(matIndex)); + } } auto selectpoint = [this, pcolor, PtNum](int geoid, Sketcher::PointPos pos) {