From 66045c0c0a6ccb2be4bee2ab2a1a9edb386d9c73 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 22 Nov 2024 15:45:44 +0800 Subject: [PATCH] .. --- forge-gui-mobile-dev/src/forge/app/Main.java | 24 ++++++++++++-------- forge-gui-mobile/src/forge/Forge.java | 4 +++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/forge-gui-mobile-dev/src/forge/app/Main.java b/forge-gui-mobile-dev/src/forge/app/Main.java index 8714712af23..2ebf437ce40 100644 --- a/forge-gui-mobile-dev/src/forge/app/Main.java +++ b/forge-gui-mobile-dev/src/forge/app/Main.java @@ -20,9 +20,21 @@ import java.util.Optional; public class Main { private static final String versionString = BuildInfo.getVersionString(); public static void main(String[] args) { + if (!OperatingSystem.isWindows()) { + /* Prevents crash on non Windows OS before creating the LWJGL3 window. + It seems it defeats the purpose of having a splash image since + this is an indicator if the LWJGL3 has booted up succesfully. */ + closeSplash(); + } new GameLauncher(versionString); } - + public static void closeSplash() { + try { + Optional.ofNullable(SplashScreen.getSplashScreen()).ifPresent(SplashScreen::close); + } catch (Exception e) { + e.printStackTrace(); + } + } public static class DesktopAdapter implements IDeviceAdapter { private final String switchOrientationFile; @@ -96,15 +108,7 @@ public class Main { @Override public void closeSplashScreen() { - // FIXME: on Linux system it can't close splashscreen image or crash with SIGSEGV? How come it works on other OS? - if (OperatingSystem.isUnix() || OperatingSystem.isSolaris()) - return; - //could throw exception.. - try { - Optional.ofNullable(SplashScreen.getSplashScreen()).ifPresent(SplashScreen::close); - } catch (Exception e) { - e.printStackTrace(); - } + closeSplash(); } @Override diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 7dafac0f1e7..8d03bdc24f2 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -159,7 +159,9 @@ public class Forge implements ApplicationListener { public void create() { //install our error handler ExceptionHandler.registerErrorHandling(); - getDeviceAdapter().closeSplashScreen(); + // closeSplashScreen() is called early on non-Windows OS so it will not crash, LWJGL3 bug on AWT Splash. + if (OperatingSystem.isWindows()) + getDeviceAdapter().closeSplashScreen(); GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android);