Fix multiple issues regarding validation cleanup

Good that I'm writing unit tests for this shit.
This commit is contained in:
JeremyStar™ 2024-05-09 15:20:22 +02:00
parent 14b5989f26
commit 17cecf5ef3
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -23,8 +23,19 @@ var singles: Array[CoreValidationSingle]
# +++ module +++ # +++ module +++
func _cleanup() -> void: func _cleanup() -> void:
# Schemas
var schemas_remove_enty: Array[CoreValidationSchema] = []
for schema in schemas:
schemas_remove_enty.append(schema)
if !is_instance_valid(schema): continue
if !is_instance_valid(schema.parent):
logger.diag("Removing schema '" + schema.name + "'")
schema.queue_free()
for schema in schemas_remove_enty:
schemas.remove_at(schemas.find(schema))
# Singles # Singles
var singles_remove_enty: Array[CoreLoggerInstance] = [] var singles_remove_enty: Array[CoreValidationSingle] = []
for single in singles: for single in singles:
singles_remove_enty.append(single) singles_remove_enty.append(single)
if !is_instance_valid(single): continue if !is_instance_valid(single): continue
@ -33,17 +44,6 @@ func _cleanup() -> void:
single.queue_free() single.queue_free()
for single in singles_remove_enty: for single in singles_remove_enty:
singles.remove_at(singles.find(single)) singles.remove_at(singles.find(single))
# Schemas
var schemas_remove_enty: Array[CoreLoggerInstance] = []
for schema in schemas:
singles_remove_enty.append(schema)
if !is_instance_valid(schema): continue
if !is_instance_valid(schema.parent):
logger.diag("Removing schema '" + schema.name + "'")
schema.queue_free()
for schema in schemas_remove_enty:
schemas.remove_at(schemas.find(schema))
func _schedule() -> void: func _schedule() -> void:
# Singles # Singles
@ -61,10 +61,12 @@ func _schedule() -> void:
# +++ data validation +++ # +++ data validation +++
## Returns a new [CoreValidationSingle] ## Returns a new [CoreValidationSingle]
func get_single(data, parent: Node) -> CoreValidationSingle: func get_single(data, parent: Node) -> CoreValidationSingle:
singles.append(parent) var single: CoreValidationSingle = CoreValidationSingle.new(core, data, parent)
return CoreValidationSingle.new(core, data, parent) singles.append(single)
return single
## Returns a new [CoreValidationSchema] ## Returns a new [CoreValidationSchema]
func get_schema(schema: Dictionary, parent: Node) -> CoreValidationSchema: func get_schema(schema_dict: Dictionary, parent: Node) -> CoreValidationSchema:
schemas.append(parent) var schema: CoreValidationSchema = CoreValidationSchema.new(core, schema_dict, parent)
return CoreValidationSchema.new(core, schema, parent) schemas.append(schema)
return schema