From 826b8f48264e779919468816ec3314106133bba9 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 14 Jan 2022 10:09:10 +0200 Subject: [PATCH] Handling for multiplayer download errors (#5958) --- .../unciv/ui/multiplayer/MultiplayerScreen.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/src/com/unciv/ui/multiplayer/MultiplayerScreen.kt b/core/src/com/unciv/ui/multiplayer/MultiplayerScreen.kt index 39944eb64f..3ecb8f8035 100644 --- a/core/src/com/unciv/ui/multiplayer/MultiplayerScreen.kt +++ b/core/src/com/unciv/ui/multiplayer/MultiplayerScreen.kt @@ -193,20 +193,20 @@ class MultiplayerScreen(previousScreen: BaseScreen) : PickerScreen() { loadingGamePopup.add("Loading latest game state...".tr()) loadingGamePopup.open() - // For whatever reason, the only way to show the popup before the ANRs started was to - // call the loadGame explicitly with a runnable on the main thread. - // Maybe this adds just enough lag for the popup to show up - - postCrashHandlingRunnable { + crashHandlingThread(name = "JoinMultiplayerGame") { try { - game.loadGame(OnlineMultiplayer().tryDownloadGame((multiplayerGames[selectedGameFile]!!.gameId))) + val gameId = multiplayerGames[selectedGameFile]!!.gameId + val gameInfo = OnlineMultiplayer().tryDownloadGame(gameId) + postCrashHandlingRunnable { game.loadGame(gameInfo) } } catch (ex: Exception) { - loadingGamePopup.close() - val errorPopup = Popup(this) - errorPopup.addGoodSizedLabel("Could not download game!") - errorPopup.row() - errorPopup.addCloseButton() - errorPopup.open() + postCrashHandlingRunnable { + loadingGamePopup.close() + val errorPopup = Popup(this) + errorPopup.addGoodSizedLabel("Could not download game!") + errorPopup.row() + errorPopup.addCloseButton() + errorPopup.open() + } } } }