Merge pull request #82953 from jsjtxietian/document-forcedraw-can-only-be-called-from-main-thread

Add thread guard for `force_draw` and update related documentation
This commit is contained in:
Yuri Sizov 2023-12-08 15:22:53 +01:00
commit dfe0f584b4
2 changed files with 2 additions and 1 deletions

View file

@ -1362,7 +1362,7 @@
<param index="0" name="swap_buffers" type="bool" default="true" />
<param index="1" name="frame_step" type="float" default="0.0" />
<description>
Forces redrawing of all viewports at once.
Forces redrawing of all viewports at once. Must be called from the main thread.
</description>
</method>
<method name="force_sync">

View file

@ -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 {