Open OffsetMOSFET opened 2 days ago
Bisecting points to #75627 as the culprit, @reduz
Went ahead and tested the results when there was a failure to find the child. It appears that it is saving the node with an autogenerated name rather than Foo
on the Orphan node.
First value is the StringName of the hashmap data.children
, second value is the name of the Node pointer in the hashmap data.children
and the third value is the name of the node passed into the remove_child
function.
Creating the node using new
on the packed scene causes the scene to be named @Node@2
and save itself as a Node
type rather than the Node3d
type as in the scene itself.
From what I have tested, inside of _init
the scene is yet to have a name, but using instantiate
will eventually set the name to the root node name, while new
does not. Setting the name to Foo
inside of _init
will make the instantiate
method of constructing work without crashing, as well as working with the new
method of constructing the packed scene.
Not as familiar with the API yet, so unsure of the best solution, but it would seem that having the packed scene set its name early on or blocking other threads of execution until the name is set would be the "proper" fix.
EDIT: Might actually be in Node thinking on it more...still not sure where or when names are typically assigned
Tested versions
4.3.1.rc
System information
Ubuntu 22.04.4 LTS 64-bit
Issue description
I have a class_name Foo that chooses its parent via a method of a Autoload/Singleton. Foo.new() works fine. However, if I have a load a packed scene whose root is Foo (load("foo.tscn")), trying to remove the child from the parent creates a "Children name does not match parent name in hashtable" error.
Closing the window via the [x] button / quit via the system context menu causes a segfault.
Freeing the object will silently crash.
Steps to reproduce
I have attached an MRP.
The class_name Foo accesses a singleton to be able to be added to the tree. The main script will load a packedscene of Foo on ready, which is when the issues should start.
Minimal reproduction project (MRP)
parent_crash.zip