Fixed EA-100532 (java.lang.AssertionError: Font null not found)

This commit is contained in:
Rustam Vishnyakov
2017-05-10 15:50:12 +03:00
parent cfd26210b0
commit 2b763f64f6
2 changed files with 7 additions and 4 deletions
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.colors;
import com.intellij.openapi.components.ServiceManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
@@ -27,6 +28,6 @@ public abstract class EditorFontCache {
}
@NotNull
public abstract Font getFont(EditorFontType key);
public abstract Font getFont(@Nullable EditorFontType key);
public abstract void reset();
}
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.colors.impl;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.editor.colors.*;
import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,13 +30,14 @@ public class EditorFontCacheImpl extends EditorFontCache {
@Override
@NotNull
public Font getFont(EditorFontType key) {
public Font getFont(@Nullable EditorFontType key) {
synchronized (myFonts) {
if (myFonts.isEmpty()) {
initFonts();
}
final Font font = myFonts.get(key);
assert font != null : "Font " + key + " not found.";
EditorFontType fontType = ObjectUtils.notNull(key, EditorFontType.PLAIN);
final Font font = myFonts.get(fontType);
assert font != null : "Font " + fontType + " not found.";
UISettings uiSettings = UISettings.getInstance();
if (uiSettings.getPresentationMode()) {
return new Font(font.getName(), font.getStyle(), uiSettings.getPresentationModeFontSize());