mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 20:59:18 +07:00
Fixed thread crashes due to concurrent actor changes in multiplayer update popups
This commit is contained in:
@ -231,7 +231,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
try {
|
try {
|
||||||
val latestGame = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
|
val latestGame = OnlineMultiplayer().tryDownloadGame(gameInfo.gameId)
|
||||||
if(gameInfo.isUpToDate && gameInfo.currentPlayer==latestGame.currentPlayer) { // we were trying to download this to see when it's our turn...nothing changed
|
if(gameInfo.isUpToDate && gameInfo.currentPlayer==latestGame.currentPlayer) { // we were trying to download this to see when it's our turn...nothing changed
|
||||||
loadingGamePopup.close()
|
Gdx.app.postRunnable { loadingGamePopup.close() }
|
||||||
return@thread
|
return@thread
|
||||||
}
|
}
|
||||||
latestGame.isUpToDate=true
|
latestGame.isUpToDate=true
|
||||||
@ -242,6 +242,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
|
Gdx.app.postRunnable { // otherwise the popups of the screen could be concurrently modified, and we'll get an unhappy thread
|
||||||
loadingGamePopup.close()
|
loadingGamePopup.close()
|
||||||
val couldntDownloadLatestGame = Popup(this)
|
val couldntDownloadLatestGame = Popup(this)
|
||||||
couldntDownloadLatestGame.addGoodSizedLabel("Couldn't download the latest game state!").row()
|
couldntDownloadLatestGame.addGoodSizedLabel("Couldn't download the latest game state!").row()
|
||||||
@ -251,6 +252,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This is private so that we will set the shouldUpdate to true instead.
|
// This is private so that we will set the shouldUpdate to true instead.
|
||||||
// That way, not only do we save a lot of unnecessary updates, we also ensure that all updates are called from the main GL thread
|
// That way, not only do we save a lot of unnecessary updates, we also ensure that all updates are called from the main GL thread
|
||||||
|
Reference in New Issue
Block a user