Mark panels removed when screen is removed

This commit is contained in:
DBotThePony 2023-08-23 16:42:04 +07:00
parent 82d46f4cf4
commit 2766a444d6
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 13 additions and 0 deletions

View File

@ -466,6 +466,11 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
}
}
override fun onClose() {
super.onClose()
panels.forEach { it.markRemoved() }
}
public override fun recalculateQuickCraftRemaining() {
super.recalculateQuickCraftRemaining()
}

View File

@ -1782,6 +1782,14 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
protected open fun beforeRemoved() {}
protected open fun onRemoved() {}
internal fun markRemoved() {
if (!isRemoved) {
isRemoved = true
onRemoved()
children.forEach { it.markRemoved() }
}
}
fun remove() {
if (isRemoved) {
return