Fix update manager not displaying self-update errors

This commit is contained in:
Henry Le Grys 2023-02-23 23:56:48 +00:00
parent 8dfb0490e3
commit 60030695b3
3 changed files with 13 additions and 8 deletions

View File

@ -105,7 +105,7 @@ public final class Launcher {
}
});
updateManager.checkForUpdate();
updateManager.checkForUpdate(null);
}
/**
@ -401,8 +401,11 @@ public final class Launcher {
/**
* Show the launcher.
*/
public void showLauncherWindow() {
mainWindowSupplier.get().setVisible(true);
public Window showLauncherWindow() {
Window window = mainWindowSupplier.get();
window.setVisible(true);
return window;
}
/**

View File

@ -132,7 +132,7 @@ public class LauncherFrame extends JFrame {
@Override
public void actionPerformed(ActionEvent e) {
loadInstances();
launcher.getUpdateManager().checkForUpdate();
launcher.getUpdateManager().checkForUpdate(LauncherFrame.this);
webView.browse(launcher.getNewsURL(), false);
}
});
@ -394,8 +394,8 @@ public class LauncherFrame extends JFrame {
@Override
public void gameClosed() {
launcher.showLauncherWindow();
launcher.getUpdateManager().checkForUpdate();
Window newLauncherWindow = launcher.showLauncherWindow();
launcher.getUpdateManager().checkForUpdate(newLauncherWindow);
}
}

View File

@ -50,7 +50,7 @@ public class UpdateManager {
return pendingUpdate != null;
}
public void checkForUpdate() {
public void checkForUpdate(final Window window) {
ListenableFuture<LatestVersionInfo> future = launcher.getExecutor().submit(new UpdateChecker(launcher));
Futures.addCallback(future, new FutureCallback<LatestVersionInfo>() {
@ -63,9 +63,11 @@ public class UpdateManager {
@Override
public void onFailure(Throwable t) {
// Error handler attached below.
}
}, SwingExecutor.INSTANCE);
SwingHelper.addErrorDialogCallback(window, future);
}
public void performUpdate(final Window window) {