From 61465ee9a12c9119940f4c7505b40a1b588035c4 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 15 May 2023 01:58:27 +0200 Subject: [PATCH] Allow showing messages from threads in Editor Log --- editor/editor_log.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 1113a10e38fc..17e873e6376b 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -43,9 +43,6 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type) { EditorLog *self = static_cast(p_self); - if (self->current != Thread::get_caller_id()) { - return; - } String err_str; if (p_errorexp && p_errorexp[0]) { @@ -58,10 +55,12 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f err_str += " (User)"; } - if (p_type == ERR_HANDLER_WARNING) { - self->add_message(err_str, MSG_TYPE_WARNING); + MessageType message_type = p_type == ERR_HANDLER_WARNING ? MSG_TYPE_WARNING : MSG_TYPE_ERROR; + + if (self->current != Thread::get_caller_id()) { + callable_mp(self, &EditorLog::add_message).bind(err_str, message_type).call_deferred(); } else { - self->add_message(err_str, MSG_TYPE_ERROR); + self->add_message(err_str, message_type); } }