Handle more platform initialization errors

This commit is contained in:
crschnick 2024-03-17 10:07:23 +00:00
parent 3a47755c73
commit 1fb68f8ca1
2 changed files with 7 additions and 5 deletions

View file

@ -36,10 +36,10 @@ public class AppBundledFonts {
private static boolean canLoadFonts() {
try {
// This can fail if the found fonts can somehow not be loaded
// This can fail if the found system fonts can somehow not be loaded
Font.getDefault();
return true;
} catch (Exception e) {
} catch (Throwable e) {
return false;
}
}

View file

@ -72,10 +72,12 @@ public enum PlatformState {
// Maybe related to https://bugs.openjdk.org/browse/JDK-8318129 as it prints the same error if not called
// The headless check is not needed though but still done
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
} catch (HeadlessException e) {
TrackEvent.warn(e.getMessage());
// Catch more than just the headless exception in case the graphics environment initialization completely fails
} catch (Throwable t) {
TrackEvent.warn(t.getMessage());
PlatformState.setCurrent(PlatformState.EXITED);
return Optional.of(e);
return Optional.of(t);
}
// Check if we have no fonts and set properties to load bundled ones