error if in class_name a variable is of that type

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Black Monkey

I get this error when I close the game:

ERROR: ~List: Condition “_first != __null” is true.
At: ./core/self_list.h:112
ERROR: ~List: Condition “_first != __null” is true.
At: ./core/self_list.h:112
WARNING: cleanup: ObjectDB instances leaked at exit (run with --verbose for details).
At: core/object.cpp:2135
ERROR: clear: Resources still in use at exit (run with --verbose for details).
At: core/resource.cpp:477

It happens if I use a autoload with classname,
and declare a variable of the same type of that classname:

extends Node
class_name Region
var child:Region

or create a function with a reference to that classname.

extends Node
class_name Region

func create_region(par:Region):

I tried Regions.queue_free() before _exit_tree() but to no prevail.

Is this type of coding not allowed?
If so, how else could I do this?

:bust_in_silhouette: Reply From: Black Monkey

I really, really don’t get it.
Even if I create a script:

extends Node2D

class_name Motorcycle

var speed = 0

and just put it somewhere in the res:// folder.
in a tree with just a Node2D, with a script:

extends Node2D

var ab = Motorcycle.new()

func _ready() -> void:
print(ab.speed)

It prints the speed!?
And I still get the same error if I close the program.
Help!

:bust_in_silhouette: Reply From: Black Monkey

I still don’t get it.
But I’ve got something working.

The script attached to a Node2D:

extends Node2D

var ab = Motorcycle.new()

func _ready() -> void:
print(ab.speed)

and in an other script , somewhere in the res:// folder:

class_name Motorcycle

var speed = 0

It prints the speed.
And when I use yet an other script:

extends Motorcycle

class_name Car
var test:Motorcycle

I am allowed to reference ‘Motorcycle’ in a variable.
And closing does not give an error.
Strange, because the ‘car’ is an extended ‘Motorcycle’
Perhaps someone can explain this, because I would like to understand.

edit:I really shouldn’t answer my own questions. (And this was the second one!)