Make notify_dependency_error only defer calls if called from secondary threads.

This commit is contained in:
Saracen 2023-09-24 13:43:10 +01:00
parent fe5b1c8d49
commit 0b0a6109b6
1 changed files with 5 additions and 1 deletions

View File

@ -230,9 +230,13 @@ public:
// Loaders can safely use this regardless which thread they are running on. // Loaders can safely use this regardless which thread they are running on.
static void notify_dependency_error(const String &p_path, const String &p_dependency, const String &p_type) { static void notify_dependency_error(const String &p_path, const String &p_dependency, const String &p_type) {
if (dep_err_notify) { if (dep_err_notify) {
if (Thread::get_caller_id() == Thread::get_main_id()) {
dep_err_notify(p_path, p_dependency, p_type);
} else {
callable_mp_static(dep_err_notify).bind(p_path, p_dependency, p_type).call_deferred(); callable_mp_static(dep_err_notify).bind(p_path, p_dependency, p_type).call_deferred();
} }
} }
}
static void set_dependency_error_notify_func(DependencyErrorNotify p_err_notify) { static void set_dependency_error_notify_func(DependencyErrorNotify p_err_notify) {
dep_err_notify = p_err_notify; dep_err_notify = p_err_notify;
} }