Fix cleanup issues
This commit is contained in:
parent
6dd45fb877
commit
143e2d3176
2 changed files with 11 additions and 5 deletions
|
@ -210,7 +210,7 @@ func unregister_custom_module(module_name: String) -> void:
|
|||
if !custom_modules.has(module_name):
|
||||
loggeri.error("Unregistering module failed: A custom module with the name \"" + module_name + "\" does not exist.")
|
||||
return
|
||||
var module: Node = get_custom_module(module_name)
|
||||
var module: Node = custom_modules[module_name]
|
||||
await module._cleanup()
|
||||
module.loggeri.queue_free()
|
||||
custom_modules_node.remove_child(module)
|
||||
|
@ -231,7 +231,7 @@ func get_custom_module(module_name: String) -> CoreBaseModule:
|
|||
## Unloads all custom modules, built-in modules, frees any of CORE's classes and lastly itself.
|
||||
func cleanup() -> void:
|
||||
loggeri.info("Cleaning up")
|
||||
for module in custom_modules_node.get_children(): unregister_custom_module(module.name)
|
||||
for module in custom_modules_node.get_children(): await unregister_custom_module(module.name)
|
||||
remove_child(custom_modules_node)
|
||||
custom_modules_node.queue_free()
|
||||
var modules_reverse: Array[String] = modules.duplicate()
|
||||
|
@ -241,6 +241,7 @@ func cleanup() -> void:
|
|||
get(module).loggeri.queue_free()
|
||||
get(module).queue_free()
|
||||
config.queue_free()
|
||||
await get_tree().process_frame
|
||||
queue_free()
|
||||
|
||||
## Returns if the framework is in development mode.
|
||||
|
|
|
@ -46,16 +46,21 @@ var config_newlines_sizelimit: int
|
|||
|
||||
# +++ module +++
|
||||
func _cleanup() -> void:
|
||||
_schedule()
|
||||
await get_tree().process_frame
|
||||
for instance in instances:
|
||||
if !is_instance_valid(instance):
|
||||
loggeri.diag("Removing instance '" + instance.name + "'")
|
||||
instance.queue_free()
|
||||
|
||||
func _schedule() -> void:
|
||||
var instances_remove_enty: Array[CoreLoggerInstance] = []
|
||||
for instance in instances:
|
||||
if !is_instance_valid(instance): continue
|
||||
if !is_instance_valid(instance.parent):
|
||||
loggeri.diag("Removing instance '" + instance.name + "'")
|
||||
instance.queue_free()
|
||||
instances.remove_at(instances.find(instance))
|
||||
instances_remove_enty.append(instance)
|
||||
for instance in instances_remove_enty:
|
||||
instances.remove_at(instances.find(instance))
|
||||
|
||||
func _pull_config() -> void:
|
||||
config_level = core.config.logger_level
|
||||
|
|
Loading…
Reference in a new issue