diff --git a/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java b/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java index 65e6d1c6c..73c04fe5f 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java +++ b/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java @@ -137,13 +137,13 @@ public class FxApplication extends Application { } private void appThemeChanged(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") UiTheme oldValue, UiTheme newValue) { - appearanceProvider.ifPresent(appearanceProvider -> { + if (appearanceProvider.isPresent() && oldValue == UiTheme.AUTOMATIC && newValue != UiTheme.AUTOMATIC) { try { - appearanceProvider.removeListener(systemInterfaceThemeListener); + appearanceProvider.get().removeListener(systemInterfaceThemeListener); } catch (UiAppearanceException e) { LOG.error("Failed to disable automatic theme switching."); } - }); + } loadSelectedStyleSheet(newValue); }