0 votes

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

https://imgur.com/a/dULq3ns <--- Image
https://imgur.com/LJ8tIBW <--- Crash

Any programming feedback is also welcome I'm still new

in Engine by (235 points)

1 Answer

+1 vote
Best answer

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.

by (64 points)
selected by

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.