Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence errors about invalid deferred callables during tests #79992

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/object/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ env.CommandNoCache(["gdvirtual.gen.inc"], "make_virtuals.py", run_in_subprocess(

env_object = env.Clone()

if env["tests"]:
env_object.Append(CPPDEFINES=["TESTS_ENABLED"])

env_object.add_source_files(env.core_sources, "*.cpp")
13 changes: 12 additions & 1 deletion core/object/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "core/core_string_names.h"
#include "core/object/class_db.h"
#include "core/object/script_language.h"
#include "thirdparty/doctest/doctest.h"

#ifdef DEBUG_ENABLED
#include "core/config/engine.h"
Expand Down Expand Up @@ -322,8 +323,18 @@ Error CallQueue::flush() {
UNLOCK_MUTEX;
#ifdef DEBUG_ENABLED
if (!message->callable.is_valid()) {
bool mute_error = false;
// The editor would cause many of these.
if (!Engine::get_singleton()->is_editor_hint()) {
if (Engine::get_singleton()->is_editor_hint()) {
mute_error = true;
}
#ifdef TESTS_ENABLED
// Tests generally create objects and don't have to care about their fate when the queue is eventually flushed.
if (!mute_error && doctest::is_running_in_test) {
mute_error = true;
}
#endif
if (!mute_error) {
ERR_PRINT("Trying to execute a deferred call/notification/set on a previously freed instance. Consider using queue_free() instead of free().");
}
} else
Expand Down