Skip to content

Commit 4348224

Browse files
Kaan0029koppor
andauthored
Fix Intel crash in ThemeManager on macOS (#13543)
* Fix ARM64 crash in ThemeManager on macOS - Add try/catch around themeWindowManager.install() to handle RuntimeException - Prevents crash when native libraries are incompatible with ARM64 architecture - Fixes #13536 * fix try catch error * Added changelog entry * adjusted changelog entry * Added try catch also for instantiations in constructor * Delete redundant changelog entry * Removed usage of temp prefix to comply with jabref conventions * changed debug message to specify intel related issue * Fix handling of non-existing null * Fix logger output * Add mssing dots * Fix exception * Fix exception ... again ... * Fix exception ... again ... * Keep silent on intel mac when switchting dark mode does not work --------- Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
1 parent 502eb07 commit 4348224

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public ThemeManager(WorkspacePreferences workspacePreferences,
7373
this.workspacePreferences = Objects.requireNonNull(workspacePreferences);
7474
this.fileUpdateMonitor = Objects.requireNonNull(fileUpdateMonitor);
7575
this.updateRunner = Objects.requireNonNull(updateRunner);
76+
// Always returns something even if the native library is not available - see https://github.com/dukke/FXThemes/issues/15
7677
this.themeWindowManager = ThemeWindowManagerFactory.create();
7778

7879
this.baseStyleSheet = StyleSheet.create(Theme.BASE_CSS).get();
@@ -121,8 +122,14 @@ private void applyDarkModeToWindow(Stage stage, boolean darkMode) {
121122
return;
122123
}
123124

124-
themeWindowManager.setDarkModeForWindowFrame(stage, darkMode);
125-
LOGGER.debug("Applied {} mode to window: {}", darkMode ? "dark" : "light", stage);
125+
try {
126+
themeWindowManager.setDarkModeForWindowFrame(stage, darkMode);
127+
LOGGER.debug("Applied {} mode to window: {}", darkMode ? "dark" : "light", stage);
128+
} catch (NoClassDefFoundError | UnsatisfiedLinkError e) {
129+
// We need to handle these exceptions because the native library may not be available on all platforms (e.g., x86).
130+
// See https://github.com/dukke/FXThemes/issues/13 for details.
131+
LOGGER.debug("Failed to set dark mode for window frame (likely due to native library compatibility issues on intel)", e);
132+
}
126133
}
127134

128135
private void applyDarkModeToAllWindows(boolean darkMode) {

0 commit comments

Comments
 (0)