diff options
Diffstat (limited to 'core/io')
| -rw-r--r-- | core/io/http_client.cpp | 5 | ||||
| -rw-r--r-- | core/io/http_client_tcp.cpp | 1 | ||||
| -rw-r--r-- | core/io/resource_loader.cpp | 3 | ||||
| -rw-r--r-- | core/io/resource_loader.h | 16 |
4 files changed, 12 insertions, 13 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 190edbfb82..09505ea05d 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -63,8 +63,9 @@ Error HTTPClient::_request_raw(Method p_method, const String &p_url, const Vecto } Error HTTPClient::_request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) { - int size = p_body.length(); - return request(p_method, p_url, p_headers, size > 0 ? (const uint8_t *)p_body.utf8().get_data() : nullptr, size); + CharString body_utf8 = p_body.utf8(); + int size = body_utf8.length(); + return request(p_method, p_url, p_headers, size > 0 ? (const uint8_t *)body_utf8.get_data() : nullptr, size); } String HTTPClient::query_string_from_dict(const Dictionary &p_dict) { diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp index 3788fa501e..2f45238951 100644 --- a/core/io/http_client_tcp.cpp +++ b/core/io/http_client_tcp.cpp @@ -60,6 +60,7 @@ Error HTTPClientTCP::connect_to_host(const String &p_host, int p_port, Ref<TLSOp } ERR_FAIL_COND_V(tls_options.is_valid() && tls_options->is_server(), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V_MSG(tls_options.is_valid() && !StreamPeerTLS::is_available(), ERR_UNAVAILABLE, "HTTPS is not available in this build."); ERR_FAIL_COND_V(conn_host.length() < HOST_MIN_LEN, ERR_INVALID_PARAMETER); if (conn_port < 0) { 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; } |
