mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Fix possible NPE
This commit is contained in:
parent
cd0c8a1649
commit
1a29d14a79
1 changed files with 11 additions and 5 deletions
|
@ -74,7 +74,7 @@ public class AppTheme {
|
|||
|
||||
try {
|
||||
if (AppPrefs.get().theme.getValue() == null) {
|
||||
setDefault(Platform.getPreferences().getColorScheme());
|
||||
setDefault();
|
||||
}
|
||||
|
||||
Platform.getPreferences().colorSchemeProperty().addListener((observableValue, colorScheme, t1) -> {
|
||||
|
@ -105,10 +105,16 @@ public class AppTheme {
|
|||
init = true;
|
||||
}
|
||||
|
||||
private static void setDefault(ColorScheme colorScheme) {
|
||||
if (colorScheme == ColorScheme.DARK) {
|
||||
AppPrefs.get().theme.setValue(Theme.getDefaultDarkTheme());
|
||||
} else {
|
||||
private static void setDefault() {
|
||||
try {
|
||||
var colorScheme = Platform.getPreferences().getColorScheme();
|
||||
if (colorScheme == ColorScheme.DARK) {
|
||||
AppPrefs.get().theme.setValue(Theme.getDefaultDarkTheme());
|
||||
} else {
|
||||
AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// The color scheme query can fail if the toolkit is not initialized properly
|
||||
AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue