Make reload_configuration() and cleanup() safer
This commit is contained in:
parent
fd4d7d2eb0
commit
09dee490e5
1 changed files with 6 additions and 3 deletions
|
@ -208,7 +208,7 @@ Thank you for using the CORE Framework to develop your application or game!""".r
|
||||||
func reload_configuration(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
|
func reload_configuration(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
|
||||||
var initialized = config != null
|
var initialized = config != null
|
||||||
if initialized: loggeri.verb("Reloading CORE's configuration")
|
if initialized: loggeri.verb("Reloading CORE's configuration")
|
||||||
if config != null: config.queue_free()
|
if is_instance_valid(config): config.free()
|
||||||
config = new_config.duplicate()
|
config = new_config.duplicate()
|
||||||
if is_devmode(): # Override configuration in development mode
|
if is_devmode(): # Override configuration in development mode
|
||||||
config.logger_level = CoreTypes.LoggerLevel.DIAG
|
config.logger_level = CoreTypes.LoggerLevel.DIAG
|
||||||
|
@ -291,20 +291,23 @@ func cleanup() -> void:
|
||||||
else:
|
else:
|
||||||
loggeri.diag("Calling cleanup hook #" + str(hook))
|
loggeri.diag("Calling cleanup hook #" + str(hook))
|
||||||
await cleanup_hooks[hook].call()
|
await cleanup_hooks[hook].call()
|
||||||
|
await get_tree().process_frame
|
||||||
loggeri.verb("Unregistering custom modules")
|
loggeri.verb("Unregistering custom modules")
|
||||||
for module in custom_modules_node.get_children(): await unregister_custom_module(module.name)
|
for module in custom_modules_node.get_children(): await unregister_custom_module(module.name)
|
||||||
|
await get_tree().process_frame
|
||||||
loggeri.verb("Removing custom module support")
|
loggeri.verb("Removing custom module support")
|
||||||
remove_child(custom_modules_node)
|
remove_child(custom_modules_node)
|
||||||
custom_modules_node.queue_free()
|
custom_modules_node.queue_free()
|
||||||
|
await get_tree().process_frame
|
||||||
loggeri.verb("Unloading built-in modules")
|
loggeri.verb("Unloading built-in modules")
|
||||||
var modules_reverse: Array[String] = modules.duplicate()
|
var modules_reverse: Array[String] = modules.duplicate()
|
||||||
modules_reverse.reverse()
|
modules_reverse.reverse()
|
||||||
for module in modules_reverse:
|
for module in modules_reverse:
|
||||||
await get(module)._cleanup()
|
await get(module)._cleanup()
|
||||||
get(module).queue_free()
|
get(module).queue_free()
|
||||||
print("Freeing configuration")
|
|
||||||
config.queue_free()
|
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
|
print("Freeing configuration")
|
||||||
|
config.free()
|
||||||
print("Freeing")
|
print("Freeing")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue