summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-05-22 13:49:11 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-05-22 13:49:11 +0200
commitfb613fd430a9033ff11a495866ce5905672decfa (patch)
tree2135af3d399b0ee9f4380de561b80cb98176d19c /editor
parenta3bbb4661b705d1c4067015855af67f0ac754836 (diff)
parent2648232fe8219a75ba9425e2c8d69f5962911ed2 (diff)
downloadredot-engine-fb613fd430a9033ff11a495866ce5905672decfa.tar.gz
Merge pull request #77251 from RandomShaper/fix_editor_mt
Make certain editor callbacks thread-safe
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp15
-rw-r--r--editor/editor_node.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 564cdf1192..c9f356b82c 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -5901,6 +5901,10 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str
}
void EditorNode::_file_access_close_error_notify(const String &p_str) {
+ callable_mp_static(&EditorNode::_file_access_close_error_notify_impl).bind(p_str).call_deferred();
+}
+
+void EditorNode::_file_access_close_error_notify_impl(const String &p_str) {
add_io_error(vformat(TTR("Unable to write to file '%s', file in use, locked or lacking permissions."), p_str));
}
@@ -6502,13 +6506,16 @@ static Node *_resource_get_edited_scene() {
}
void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich) {
- EditorNode *en = static_cast<EditorNode *>(p_this);
+ callable_mp_static(&EditorNode::_print_handler_impl).bind(p_string, p_error, p_rich).call_deferred();
+}
+
+void EditorNode::_print_handler_impl(const String &p_string, bool p_error, bool p_rich) {
if (p_error) {
- en->log->add_message(p_string, EditorLog::MSG_TYPE_ERROR);
+ singleton->log->add_message(p_string, EditorLog::MSG_TYPE_ERROR);
} else if (p_rich) {
- en->log->add_message(p_string, EditorLog::MSG_TYPE_STD_RICH);
+ singleton->log->add_message(p_string, EditorLog::MSG_TYPE_STD_RICH);
} else {
- en->log->add_message(p_string, EditorLog::MSG_TYPE_STD);
+ singleton->log->add_message(p_string, EditorLog::MSG_TYPE_STD);
}
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index b5f84a3204..814899e169 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -518,8 +518,10 @@ private:
static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog);
static void _file_access_close_error_notify(const String &p_str);
+ static void _file_access_close_error_notify_impl(const String &p_str);
static void _print_handler(void *p_this, const String &p_string, bool p_error, bool p_rich);
+ static void _print_handler_impl(const String &p_string, bool p_error, bool p_rich);
static void _resource_saved(Ref<Resource> p_resource, const String &p_path);
static void _resource_loaded(Ref<Resource> p_resource, const String &p_path);