From 8d91cb90dc52532a3676d66ba39256cdaa9b5801 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 14 Apr 2019 22:18:40 +0300 Subject: [PATCH] Solved another rare concurrency error --- core/src/com/unciv/logic/city/CityConstructions.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index ac3b176846..7fcc31fc6a 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -53,16 +53,18 @@ class CityConstructions { } fun getCityProductionTextForCityButton(): String { - var result = currentConstruction.tr() - if (SpecialConstruction.getSpecialConstructions().none { it.name==currentConstruction }) - result += "\r\n" + turnsToConstruction(currentConstruction) + " {turns}".tr() + val currentConstructionSnapshot = currentConstruction // See below + var result = currentConstructionSnapshot .tr() + if (SpecialConstruction.getSpecialConstructions().none { it.name==currentConstructionSnapshot }) + result += "\r\n" + turnsToConstruction(currentConstructionSnapshot ) + " {turns}".tr() return result } fun getProductionForTileInfo(): String { - var result = currentConstruction.tr() - if (SpecialConstruction.getSpecialConstructions().none { it.name==currentConstruction }) - result += "\r\n{in} ".tr() + turnsToConstruction(currentConstruction) + " {turns}".tr() + val currentConstructionSnapshot = currentConstruction // this is because there were rare errors tht I assume were caused because currentContruction changed on another thread + var result = currentConstructionSnapshot.tr() + if (SpecialConstruction.getSpecialConstructions().none { it.name==currentConstructionSnapshot }) + result += "\r\n{in} ".tr() + turnsToConstruction(currentConstructionSnapshot) + " {turns}".tr() return result }