Call queue_free() on scenes during removal

This commit is contained in:
JeremyStar™ 2024-03-31 16:19:22 +02:00
parent 96c17c7287
commit 899bd338df
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -77,11 +77,21 @@ func remove_scene(sname: String, force_remove: bool = false) -> bool:
if force_remove: await logger.crashf("Sms", "force_remove = true is not allowed", true)
logger.verbf("Sms", "Removing scene \"" + sname + "\"")
match(exists(sname)):
CoreTypes.SceneType.DEBUG: scenes_debug.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.CUTSCENE: scenes_cutscene.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.MENU: scenes_menu.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.MAIN: scenes_main.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.BACKGROUND: scenes_background.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.DEBUG:
scenes_debug.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.CUTSCENE:
scenes_cutscene.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.MENU:
scenes_menu.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.MAIN:
scenes_main.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.BACKGROUND:
scenes_background.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.NONE:
logger.errorf("Sms", "Scene \"" + sname + "\" does not exist")
return false