mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-17 15:57:18 -04:00
Fix NPE when the game launched and suddenly crashes
This commit is contained in:
parent
75031a04cc
commit
34f7774ce9
@ -172,13 +172,17 @@ public final class LauncherHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop(boolean success, TaskExecutor executor) {
|
public void onStop(boolean success, TaskExecutor executor) {
|
||||||
if (!success) {
|
if (!success && !Controllers.isStopped()) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
Controllers.closeDialog(launchingStepsPane);
|
// Check if the application has stopped
|
||||||
if (executor.getLastException() != null)
|
// because onStop will be invoked if tasks fail when the executor service shut down.
|
||||||
Controllers.dialog(I18nException.getStackTrace(executor.getLastException()),
|
if (!Controllers.isStopped()) {
|
||||||
scriptFile == null ? Launcher.i18n("launch.failed") : Launcher.i18n("version.launch_script.failed"),
|
Controllers.closeDialog(launchingStepsPane);
|
||||||
MessageBox.ERROR_MESSAGE);
|
if (executor.getLastException() != null)
|
||||||
|
Controllers.dialog(I18nException.getStackTrace(executor.getLastException()),
|
||||||
|
scriptFile == null ? Launcher.i18n("launch.failed") : Launcher.i18n("version.launch_script.failed"),
|
||||||
|
MessageBox.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
launchingStepsPane.setExecutor(null);
|
launchingStepsPane.setExecutor(null);
|
||||||
|
@ -157,7 +157,8 @@ public final class Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void closeDialog(Region content) {
|
public static void closeDialog(Region content) {
|
||||||
|
if (stage == null) // shut down
|
||||||
|
return;
|
||||||
decorator.closeDialog(content);
|
decorator.closeDialog(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +175,10 @@ public final class Controllers {
|
|||||||
getLeftPaneController().showUpdate();
|
getLeftPaneController().showUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isStopped() {
|
||||||
|
return decorator == null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
mainPage = null;
|
mainPage = null;
|
||||||
settingsPage = null;
|
settingsPage = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user