diff options
| author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2024-06-19 09:54:01 +0200 |
|---|---|---|
| committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2024-06-19 09:54:01 +0200 |
| commit | e6d930b31f1042fd01d3824947b48cfdab939c0e (patch) | |
| tree | 9fd1fa56deb0336eca3dbf15054d9931ea8b4a6f /scene/resources/animated_texture.cpp | |
| parent | 19bf77f66635c53cc28d54784a9a2333f4a8d289 (diff) | |
| download | redot-engine-e6d930b31f1042fd01d3824947b48cfdab939c0e.tar.gz | |
AnimatedTexture: Fix crash when loaded from a thread
Diffstat (limited to 'scene/resources/animated_texture.cpp')
| -rw-r--r-- | scene/resources/animated_texture.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scene/resources/animated_texture.cpp b/scene/resources/animated_texture.cpp index 842a398327..f13f15539d 100644 --- a/scene/resources/animated_texture.cpp +++ b/scene/resources/animated_texture.cpp @@ -270,13 +270,18 @@ void AnimatedTexture::_bind_methods() { BIND_CONSTANT(MAX_FRAMES); } +void AnimatedTexture::_finish_non_thread_safe_setup() { + RenderingServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy)); +} + AnimatedTexture::AnimatedTexture() { //proxy = RS::get_singleton()->texture_create(); proxy_ph = RS::get_singleton()->texture_2d_placeholder_create(); proxy = RS::get_singleton()->texture_proxy_create(proxy_ph); RenderingServer::get_singleton()->texture_set_force_redraw_if_visible(proxy, true); - RenderingServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy)); + + MessageQueue::get_main_singleton()->push_callable(callable_mp(this, &AnimatedTexture::_finish_non_thread_safe_setup)); } AnimatedTexture::~AnimatedTexture() { |
