Skip to content

Commit

Permalink
#4380 Preferences : Changing scene font size when geo mech view is op…
Browse files Browse the repository at this point in the history
…en causes crash

Guard access to annotationCollection, as this is nullptr for geo mech views.
  • Loading branch information
magnesj committed Apr 30, 2019
1 parent fccae4f commit df62a41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ApplicationCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
}

RimGridView* gridView = dynamic_cast<RimGridView*>(rim3dView);
if (gridView)
if (gridView && gridView->annotationCollection())
{
RiaFontCache::FontSize oldFontSize = oldPreferences->defaultAnnotationFontSize();
existingObjectsWithCustomFonts = gridView->annotationCollection()->hasTextAnnotationsWithCustomFontSize(oldFontSize);
Expand Down
27 changes: 17 additions & 10 deletions ApplicationCode/ProjectDataModel/RimGridView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,12 @@ bool RimGridView::hasCustomFontSizes(RiaDefines::FontSettingType fontSettingType
bool hasCustomFonts = Rim3dView::hasCustomFontSizes(fontSettingType, defaultFontSize);
if (fontSettingType == RiaDefines::ANNOTATION_FONT)
{
auto annotations = annotationCollection();
RiaFontCache::FontSize defaultFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize(defaultFontSize);
hasCustomFonts = annotations->hasTextAnnotationsWithCustomFontSize(defaultFontSizeEnum) || hasCustomFonts;
auto annotations = annotationCollection();
if (annotations)
{
RiaFontCache::FontSize defaultFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize(defaultFontSize);
hasCustomFonts = annotations->hasTextAnnotationsWithCustomFontSize(defaultFontSizeEnum) || hasCustomFonts;
}
}
return hasCustomFonts;
}
Expand All @@ -313,14 +316,18 @@ bool RimGridView::applyFontSize(RiaDefines::FontSettingType fontSettingType,
bool anyChange = Rim3dView::applyFontSize(fontSettingType, oldFontSize, fontSize, forceChange);
if (fontSettingType == RiaDefines::ANNOTATION_FONT)
{
auto annotations = annotationCollection();
RiaFontCache::FontSize oldFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize(oldFontSize);
RiaFontCache::FontSize newFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize(fontSize);
bool applyFontSizes = forceChange || !annotations->hasTextAnnotationsWithCustomFontSize(oldFontSizeEnum);

if (applyFontSizes)
auto annotations = annotationCollection();
if (annotations)
{
anyChange = annotations->applyFontSizeToAllTextAnnotations(oldFontSizeEnum, newFontSizeEnum, forceChange) || anyChange;
RiaFontCache::FontSize oldFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize(oldFontSize);
RiaFontCache::FontSize newFontSizeEnum = RiaFontCache::fontSizeEnumFromPointSize(fontSize);
bool applyFontSizes = forceChange || !annotations->hasTextAnnotationsWithCustomFontSize(oldFontSizeEnum);

if (applyFontSizes)
{
anyChange =
annotations->applyFontSizeToAllTextAnnotations(oldFontSizeEnum, newFontSizeEnum, forceChange) || anyChange;
}
}
}
return anyChange;
Expand Down

0 comments on commit df62a41

Please sign in to comment.