mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 14:30:56 +03:00
Theme Editor: fixed StackOverflowError when setting "defaultFont" to non-font value (e.g. defaultFont = #fff)
This commit is contained in:
@@ -177,7 +177,8 @@ class FlatThemePreview
|
|||||||
|
|
||||||
Object value = textArea.propertiesSupport.getParsedProperty( (String) key );
|
Object value = textArea.propertiesSupport.getParsedProperty( (String) key );
|
||||||
|
|
||||||
inGetDefaultFont = "defaultFont".equals( key );
|
boolean isDefaultFont = "defaultFont".equals( key );
|
||||||
|
inGetDefaultFont = isDefaultFont;
|
||||||
try {
|
try {
|
||||||
if( value instanceof LazyValue ) {
|
if( value instanceof LazyValue ) {
|
||||||
value = lazyValueCache.computeIfAbsent( (LazyValue) value, k -> {
|
value = lazyValueCache.computeIfAbsent( (LazyValue) value, k -> {
|
||||||
@@ -191,6 +192,12 @@ class FlatThemePreview
|
|||||||
|
|
||||||
// System.out.println( key + " = " + value );
|
// System.out.println( key + " = " + value );
|
||||||
|
|
||||||
|
// for "defaultFont" never return a value that is not a font
|
||||||
|
// (e.g. a color for "defaultFont = #fff") to avoid StackOverflowError
|
||||||
|
// in Active.createValue()
|
||||||
|
if( isDefaultFont && !(value instanceof Font) )
|
||||||
|
return null;
|
||||||
|
|
||||||
// If value is null and is a property that is defined in a core theme,
|
// If value is null and is a property that is defined in a core theme,
|
||||||
// then force the value to null.
|
// then force the value to null.
|
||||||
// This is necessary for cases where the current application Laf defines a property
|
// This is necessary for cases where the current application Laf defines a property
|
||||||
@@ -198,7 +205,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 ) && !"defaultFont".equals( key ) )
|
if( value == null && FlatThemePropertiesBaseManager.getDefindedCoreKeys().contains( key ) && !isDefaultFont )
|
||||||
return FlatLaf.NULL_VALUE;
|
return FlatLaf.NULL_VALUE;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public class FlatThemePreviewFonts
|
|||||||
|
|
||||||
updateDescription( previewLabel.getFont() );
|
updateDescription( previewLabel.getFont() );
|
||||||
previewLabel.addPropertyChangeListener( "font", e -> {
|
previewLabel.addPropertyChangeListener( "font", e -> {
|
||||||
updateDescription( (Font) e.getNewValue() );
|
updateDescription( previewLabel.getFont() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user