#4380 Preferences : Changing scene font size when geo mech view is open causes crash

Guard access to annotationCollection, as this is nullptr for geo mech views.
This commit is contained in:
Magne Sjaastad
2019-04-30 07:39:24 +02:00
parent fccae4f1cc
commit df62a41397
2 changed files with 18 additions and 11 deletions

View File

@@ -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;
}
@@ -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;