From b88b84ce18c8620a1b451a635f12daa90db5209f Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Sat, 7 Oct 2023 18:53:02 +0800 Subject: [PATCH] Add thread guard for force_draw and update relared doc force_draw must be called from main thread --- doc/classes/RenderingServer.xml | 2 +- servers/rendering/rendering_server_default.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index e5409a6e8aca..ae08085c9080 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -1362,7 +1362,7 @@ - Forces redrawing of all viewports at once. + Forces redrawing of all viewports at once. Must be called from the main thread. diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index 65a6da8ac308..77fe91e4c9d5 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -379,6 +379,7 @@ void RenderingServerDefault::sync() { } void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) { + ERR_FAIL_COND_MSG(!Thread::is_main_thread(), "Manually triggering the draw function from the RenderingServer can only be done on the main thread. Call this function from the main thread or use call_deferred()."); if (create_thread) { command_queue.push(this, &RenderingServerDefault::_thread_draw, p_swap_buffers, frame_step); } else {