Skip to content

Commit 44f30d9

Browse files
committed
Crashfix when gui gets closed by kicking from the server
1 parent f074faf commit 44f30d9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

common/src/main/kotlin/com/lambda/gui/api/LambdaGui.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.lambda.graphics.animation.AnimationTicker
99
import com.lambda.gui.api.component.core.IComponent
1010
import com.lambda.gui.impl.AbstractClickGui
1111
import com.lambda.module.Module
12+
import com.lambda.threading.runSafe
1213
import com.lambda.util.KeyCode
1314
import com.lambda.util.Mouse
1415
import com.lambda.util.Nameable
@@ -79,14 +80,16 @@ abstract class LambdaGui(
7980
override fun removed() {
8081
onEvent(GuiEvent.Hide())
8182

82-
// quick crashfix (is there any other way to prevent gui being closed twice?)
83-
mc.currentScreen = null
84-
owner?.disable()
85-
mc.currentScreen = this
83+
runSafe {
84+
// quick crashfix (is there any other way to prevent gui being closed twice?)
85+
mc.currentScreen = null
86+
owner?.disable()
87+
mc.currentScreen = this@LambdaGui
8688

87-
closingAction?.let {
88-
recordRenderCall(it)
89-
closingAction = null
89+
closingAction?.let {
90+
recordRenderCall(it)
91+
closingAction = null
92+
}
9093
}
9194
}
9295

0 commit comments

Comments
 (0)