From 05ae6fc81f6ae577d1123b28ca8c19ee510b127e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A4in=C3=B6=20M=C3=A4kel=C3=A4?= Date: Sun, 7 Jun 2020 19:14:27 +0300 Subject: [PATCH] Don't draw text on worker threads (#2701) Drawing text requires OpenGL context if new characters need to be rendered. --- .../unciv/ui/mapeditor/MapEditorMenuPopup.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt index 7514c1ff..1c78a218 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt @@ -55,7 +55,9 @@ class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): Popup(mapEditorScree try { MapSaver.saveMap(mapEditorScreen.mapName, mapEditorScreen.tileMap) close() - ResponsePopup("Map saved", mapEditorScreen) // todo - add this text to translations + Gdx.app.postRunnable { + ResponsePopup("Map saved", mapEditorScreen) // todo - add this text to translations + } } catch (ex: Exception) { ex.printStackTrace() Gdx.app.postRunnable { @@ -97,16 +99,20 @@ class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): Popup(mapEditorScree DropBox.uploadFile("/Maps/" + mapEditorScreen.mapName, gzippedMap) remove() - val uploadedSuccessfully = Popup(screen) - uploadedSuccessfully.addGoodSizedLabel("Map uploaded successfully!").row() - uploadedSuccessfully.addCloseButton() - uploadedSuccessfully.open() + Gdx.app.postRunnable { + val uploadedSuccessfully = Popup(screen) + uploadedSuccessfully.addGoodSizedLabel("Map uploaded successfully!").row() + uploadedSuccessfully.addCloseButton() + uploadedSuccessfully.open() + } } catch (ex: Exception) { remove() - val couldNotUpload = Popup(screen) - couldNotUpload.addGoodSizedLabel("Could not upload map!").row() - couldNotUpload.addCloseButton() - couldNotUpload.open() + Gdx.app.postRunnable { + val couldNotUpload = Popup(screen) + couldNotUpload.addGoodSizedLabel("Could not upload map!").row() + couldNotUpload.addCloseButton() + couldNotUpload.open() + } } } }