Skip to content

Commit 6b3936c

Browse files
committed
Sketcher: [skip ci] fix segmentation fault in ViewProviderSketch::drawConstraintIcons()
For more details see: https://forum.freecadweb.org/viewtopic.php?f=19&t=54193
1 parent ddaa29d commit 6b3936c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Mod/Sketcher/Gui/ViewProviderSketch.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,6 +3379,7 @@ void ViewProviderSketch::drawConstraintIcons()
33793379

33803380
// Find the Constraint Icon SoImage Node
33813381
SoSeparator *sep = static_cast<SoSeparator *>(edit->constrGroup->getChild(constrId));
3382+
int numChildren = sep->getNumChildren();
33823383

33833384
SbVec3f absPos;
33843385
// Somewhat hacky - we use SoZoomTranslations for most types of icon,
@@ -3442,14 +3443,16 @@ void ViewProviderSketch::drawConstraintIcons()
34423443
// So, to get the position of the second icon, we add the two translations together
34433444
//
34443445
// See note ~30 lines up.
3445-
translationPtr = static_cast<SoTranslation *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_TRANSLATION));
3446-
if(dynamic_cast<SoZoomTranslation *>(translationPtr))
3447-
thisIcon.position += static_cast<SoZoomTranslation *>(translationPtr)->abPos.getValue();
3448-
else
3449-
thisIcon.position += translationPtr->translation.getValue();
3446+
if (numChildren > CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID) {
3447+
translationPtr = static_cast<SoTranslation *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_TRANSLATION));
3448+
if(dynamic_cast<SoZoomTranslation *>(translationPtr))
3449+
thisIcon.position += static_cast<SoZoomTranslation *>(translationPtr)->abPos.getValue();
3450+
else
3451+
thisIcon.position += translationPtr->translation.getValue();
34503452

3451-
thisIcon.destination = dynamic_cast<SoImage *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_ICON));
3452-
thisIcon.infoPtr = static_cast<SoInfo *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID));
3453+
thisIcon.destination = dynamic_cast<SoImage *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_ICON));
3454+
thisIcon.infoPtr = static_cast<SoInfo *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID));
3455+
}
34533456
}
34543457
else {
34553458
if ((*it)->Name.empty())

0 commit comments

Comments
 (0)