Game crashes on get_tree.quit()

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

Currently in final stages of development using 2.1.

I have a button in my main menu that quits the game but the game crashes when I click it. It only happens in my exported game (Windows Desktop).

I have a simple function in my main node for quitting the game:

func mainQuit():

In the debug window the errors are:

Can anyone please explain how to fix this?

I have first 2 error messages in 3.0.2, no crash.
Try using call_deferred(), maybe.

hilfazer | 2018-05-04 08:33

Two things worth checking.

First you can see if you have leaks. Using a Debug build (which looks like what you’re doing already), from the command prompt you use the -v flag. C:\Exported Game Folder> "my game.exe" -v

It will show all the resources loading when it opens.

When it closes it may report resources that haven’t been freed.

The second possibility is a bug with ColorN(). Search your code for the use of ColorN() and try replacing them.

I had an issue where if you use these in the highest scope of a GDScript, they have some sort of bug/leak in the backend that hangs up the quit().

extends Node2D

var my_color = ColorN("white") # Change these to Color(1,1,1), etc.

func _ready():

This is an issue I found in 2.1: ColorN() can cause game to crash before SceneTree.quit() completes. · Issue #18216 · godotengine/godot · GitHub

avencherus | 2018-05-04 11:56