diff options
Diffstat (limited to 'core/io')
| -rw-r--r-- | core/io/resource_loader.cpp | 3 | ||||
| -rw-r--r-- | core/io/resource_loader.h | 16 |
2 files changed, 8 insertions, 11 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index a27341dd2c..f852e8d382 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -1136,10 +1136,7 @@ void ResourceLoader::initialize() {} void ResourceLoader::finalize() {} ResourceLoadErrorNotify ResourceLoader::err_notify = nullptr; -void *ResourceLoader::err_notify_ud = nullptr; - DependencyErrorNotify ResourceLoader::dep_err_notify = nullptr; -void *ResourceLoader::dep_err_notify_ud = nullptr; bool ResourceLoader::create_missing_resources_if_class_unavailable = false; bool ResourceLoader::abort_on_missing_resource = true; diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index ffe9d5de9a..592befb603 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -89,8 +89,8 @@ public: VARIANT_ENUM_CAST(ResourceFormatLoader::CacheMode) -typedef void (*ResourceLoadErrorNotify)(void *p_ud, const String &p_text); -typedef void (*DependencyErrorNotify)(void *p_ud, const String &p_loading, const String &p_which, const String &p_type); +typedef void (*ResourceLoadErrorNotify)(const String &p_text); +typedef void (*DependencyErrorNotify)(const String &p_loading, const String &p_which, const String &p_type); typedef Error (*ResourceLoaderImport)(const String &p_path); typedef void (*ResourceLoadedCallback)(Ref<Resource> p_resource, const String &p_path); @@ -218,24 +218,24 @@ public: static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load = p_timestamp; } static bool get_timestamp_on_load() { return timestamp_on_load; } + // Loaders can safely use this regardless which thread they are running on. static void notify_load_error(const String &p_err) { if (err_notify) { - err_notify(err_notify_ud, p_err); + callable_mp_static(err_notify).bind(p_err).call_deferred(); } } - static void set_error_notify_func(void *p_ud, ResourceLoadErrorNotify p_err_notify) { + static void set_error_notify_func(ResourceLoadErrorNotify p_err_notify) { err_notify = p_err_notify; - err_notify_ud = p_ud; } + // 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) { if (dep_err_notify) { - dep_err_notify(dep_err_notify_ud, p_path, p_dependency, p_type); + callable_mp_static(dep_err_notify).bind(p_path, p_dependency, p_type).call_deferred(); } } - static void set_dependency_error_notify_func(void *p_ud, DependencyErrorNotify p_err_notify) { + static void set_dependency_error_notify_func(DependencyErrorNotify p_err_notify) { dep_err_notify = p_err_notify; - dep_err_notify_ud = p_ud; } static void set_abort_on_missing_resources(bool p_abort) { abort_on_missing_resource = p_abort; } |
