Skip to content

Commit

Permalink
Merge pull request #6605 from kevlahnota/master2
Browse files Browse the repository at this point in the history
Fix crash on Splashscreen
  • Loading branch information
kevlahnota authored Nov 22, 2024
2 parents c773e39 + 66045c0 commit 2a499d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 14 additions & 10 deletions forge-gui-mobile-dev/src/forge/app/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@
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;

Expand Down Expand Up @@ -96,15 +108,7 @@ public void exit() {

@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
Expand Down
4 changes: 3 additions & 1 deletion forge-gui-mobile/src/forge/Forge.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ public static Localizer getLocalizer() {
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);

Expand Down

0 comments on commit 2a499d7

Please sign in to comment.