Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Don't flush the message queue before a MainLoop is iterating

HP van Braam7ab83282045b
diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp
index 5b97eb5f621..79a3ba144ee 100644
--- a/core/object/message_queue.cpp
+++ b/core/object/message_queue.cpp
@@ -31,6 +31,7 @@
#include "message_queue.h"
#include "core/config/project_settings.h"
+#include "main/main.h"
#include <cstdio>
@@ -222,6 +223,10 @@ void CallQueue::_call_function(const Callable &p_callable, const Variant *p_args
}
Error CallQueue::flush() {
+ if (!Main::is_iterating()) {
+ return ERR_BUSY;
+ }
+
LOCK_MUTEX;
if (pages.is_empty()) {
diff --git a/main/main.cpp b/main/main.cpp
index b8a7c6c3565..2a97b93c912 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -875,6 +875,7 @@ Error Main::test_setup() {
ClassDB::set_current_api(ClassDB::API_NONE);
+ iterating++;
_start_success = true;
return OK;
@@ -883,6 +884,7 @@ Error Main::test_setup() {
// The order is the same as in `Main::cleanup()`.
void Main::test_cleanup() {
ERR_FAIL_COND(!_start_success);
+ iterating--;
// Printing in the usual way can become problematic during/after cleanup.
CoreGlobals::print_ready = false;