3.1.1 Project crashes in 3.2.1

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

Two of my projects have problems in 3.2.1 that 3.1.1 didn’t have.
One of the projects crashes in 3.2.1 without any errors and the other one is telling me I’m trying to connect an invalid instance when trying to connect to its direct child node weirdly enough it works when connect them through the Godot’s UI instead using code.

None of these problems are present when using the same project in version 3.1.1

This is the project which crashes in 3.2.1 :

The ticket Scene crashes when you create an object pressing the “+” Button and then remove it by pressing the “-” Button

Imgur: The magic of the Internet <— Image
Imgur: The magic of the Internet <— Crash

Any programming feedback is also welcome I’m still new

:bust_in_silhouette: Reply From: MintSoda

Just change instance.free() in Column.gd to instance.queue_free() like the comment # Turn this into a Deferred functionsaid. It’s the same as call_deferred('free').

Most of the time, it’s better to use queue_free() rather than free(). It queues all the nodes that you want to delete, and destroys them all together at the end of current frame. It ensure all node are safe to delete.

free() destroys the node immediately, but if the node is still in the scene tree, or if the node is emitting a signal or calling a function, it crashes the game.



if not is_instance_valid(instance):

works too. (This code is just for demonstration of the reason behind. Practically, just use queue_free().

But I’m really NOT sure why it worked in 3.1. Someone needs to tell me why.

Thanks a lot for taking the time to check the project out I couldn’t figure it out and since it works in 3.1.1 I assumed it was a 3.2.1 problem.

IHate | 2020-04-27 17:16