godotengine / godotengine/godot-docs

Unclear how to "correctly clean up" a thread upon quit

Open
#6,168 3 comments 0 reactions 0 assignees View on GitHub
area:manual enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:** 3.5

**Issue description:**

My game is loading a lot of data in a thread upon its initial stage, and If I quit the game I'm working on (with Alt+F4 on Windows) before this initial data has been loaded, I see the following error on the console (in verbose mode):

```
ERROR: Attempted get on a deleted object.
at: get_named (core/variant_op.cpp:1693)
ERROR: Attempted method check on a deleted object.
at: has_method (core/variant_call.cpp:1434)
SCRIPT ERROR: Invalid get index 'some_property_on_my_data_object' (on base: 'previously freed instance').
at: some_method_on_my_data_object (res://Autoloads/MyDataStoreThatLoadsWithAThread.gd:66)
ERROR: Reference to a Thread object was lost while the thread is still running...
at: (core/bind/core_bind.cpp:2802)
WARNING: A Thread object has been destroyed without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread.
at: ~Thread (core/os/thread.cpp:124)
```

The `Thread` object doesn't seem to have a way to *abort* and throw it away. What's the proper way to discard a thread?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.