mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
Theme Editor: fixed StackOverflowError when adding "defaultFont" key to properties file
This commit is contained in:
@@ -49,6 +49,7 @@ class FlatThemePreview
|
|||||||
|
|
||||||
private final Map<LazyValue, Object> lazyValueCache = new WeakHashMap<>();
|
private final Map<LazyValue, Object> lazyValueCache = new WeakHashMap<>();
|
||||||
private int runWithUIDefaultsGetterLevel;
|
private int runWithUIDefaultsGetterLevel;
|
||||||
|
private boolean inGetDefaultFont;
|
||||||
|
|
||||||
FlatThemePreview( FlatSyntaxTextArea textArea ) {
|
FlatThemePreview( FlatSyntaxTextArea textArea ) {
|
||||||
this.textArea = textArea;
|
this.textArea = textArea;
|
||||||
@@ -158,6 +159,11 @@ class FlatThemePreview
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object getUIDefaultProperty( Object key ) {
|
Object getUIDefaultProperty( Object key ) {
|
||||||
|
// avoid StackOverflowError because "defaultFont" value is an active value
|
||||||
|
// that itself uses UIManager.getFont( "defaultFont" ) to get base font
|
||||||
|
if( inGetDefaultFont )
|
||||||
|
return null;
|
||||||
|
|
||||||
if( !(key instanceof String) )
|
if( !(key instanceof String) )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -167,12 +173,18 @@ class FlatThemePreview
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
Object value = textArea.propertiesSupport.getParsedProperty( (String) key );
|
Object value = textArea.propertiesSupport.getParsedProperty( (String) key );
|
||||||
if( value instanceof LazyValue ) {
|
|
||||||
value = lazyValueCache.computeIfAbsent( (LazyValue) value, k -> {
|
inGetDefaultFont = "defaultFont".equals( key );
|
||||||
return k.createValue( null );
|
try {
|
||||||
} );
|
if( value instanceof LazyValue ) {
|
||||||
} else if( value instanceof ActiveValue )
|
value = lazyValueCache.computeIfAbsent( (LazyValue) value, k -> {
|
||||||
value = ((ActiveValue)value).createValue( null );
|
return k.createValue( null );
|
||||||
|
} );
|
||||||
|
} else if( value instanceof ActiveValue )
|
||||||
|
value = ((ActiveValue)value).createValue( null );
|
||||||
|
} finally {
|
||||||
|
inGetDefaultFont = false;
|
||||||
|
}
|
||||||
|
|
||||||
// System.out.println( key + " = " + value );
|
// System.out.println( key + " = " + value );
|
||||||
|
|
||||||
@@ -183,7 +195,7 @@ class FlatThemePreview
|
|||||||
// E.g. FlatLightLaf defines Button.focusedBackground, but in FlatDarkLaf
|
// E.g. FlatLightLaf defines Button.focusedBackground, but in FlatDarkLaf
|
||||||
// it is not defined. Without this code, the preview for FlatDarkLaf would use
|
// it is not defined. Without this code, the preview for FlatDarkLaf would use
|
||||||
// Button.focusedBackground from FlatLightLaf if FlatLightLaf is the current application Laf.
|
// Button.focusedBackground from FlatLightLaf if FlatLightLaf is the current application Laf.
|
||||||
if( value == null && FlatThemePropertiesBaseManager.getDefindedCoreKeys().contains( key ) )
|
if( value == null && FlatThemePropertiesBaseManager.getDefindedCoreKeys().contains( key ) && !"defaultFont".equals( key ) )
|
||||||
return FlatLaf.NULL_VALUE;
|
return FlatLaf.NULL_VALUE;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
Reference in New Issue
Block a user