瀏覽代碼

only remove system theme change listener, if one was previously registered.

Armin Schrenk 4 年之前
父節點
當前提交
a17b416262
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java

+ 3 - 3
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<? extends UiTheme> 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);
 	}