crash properly if gui preparing error occurs

This commit is contained in:
Bixilon 2022-12-16 12:24:36 +01:00
parent 67be1fac2e
commit c82981eb7a
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 4 additions and 3 deletions

View File

@ -328,7 +328,7 @@ class RenderWindow(
runnable()
} catch (error: Throwable) {
error.printStackTrace()
Exception("Exception in rendering: $connection", error).crash()
Exception("Exception in rendering: ${connection.connectionId}", error).crash()
}
}
}

View File

@ -18,6 +18,7 @@ import de.bixilon.kutil.concurrent.pool.ThreadPool
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
import de.bixilon.kutil.latch.CountUpAndDownLatch
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.kutil.time.TimeUtil.millis
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
import de.bixilon.minosoft.gui.rendering.renderer.drawable.AsyncDrawable
@ -29,7 +30,7 @@ interface GUIElementDrawer {
var lastTickTime: Long
fun tickElements(elements: Collection<GUIElement>) {
val time = TimeUtil.millis
val time = millis()
val latch = CountUpAndDownLatch(1)
if (time - lastTickTime > ProtocolDefinition.TICK_TIME) {
for (element in elements) {
@ -71,7 +72,7 @@ interface GUIElementDrawer {
if (element is LayoutedGUIElement<*>) {
latch.inc()
element.prepare()
DefaultThreadPool += ThreadPoolRunnable(priority = ThreadPool.HIGH) { element.prepareAsync(); latch.dec() }
guiRenderer.renderWindow.runAsync { element.prepareAsync(); latch.dec() }
}
}
latch.dec()