Skip to content

Commit

Permalink
Sketcher: [skip ci] fix segmentation fault in ViewProviderSketch::dra…
Browse files Browse the repository at this point in the history
…wConstraintIcons()

For more details see: https://forum.freecadweb.org/viewtopic.php?f=19&t=54193
  • Loading branch information
wwmayer committed Jan 11, 2021
1 parent ddaa29d commit 6b3936c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -3379,6 +3379,7 @@ void ViewProviderSketch::drawConstraintIcons()

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

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

thisIcon.destination = dynamic_cast<SoImage *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_ICON));
thisIcon.infoPtr = static_cast<SoInfo *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID));
thisIcon.destination = dynamic_cast<SoImage *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_ICON));
thisIcon.infoPtr = static_cast<SoInfo *>(sep->getChild(CONSTRAINT_SEPARATOR_INDEX_SECOND_CONSTRAINTID));
}
}
else {
if ((*it)->Name.empty())
Expand Down

0 comments on commit 6b3936c

Please sign in to comment.