diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 2 | ||||
-rw-r--r-- | core/core_bind.cpp | 2 | ||||
-rw-r--r-- | core/debugger/remote_debugger.cpp | 1 | ||||
-rw-r--r-- | core/io/http_client.cpp | 5 | ||||
-rw-r--r-- | core/os/thread.cpp | 24 | ||||
-rw-r--r-- | core/os/thread.h | 5 | ||||
-rw-r--r-- | core/variant/variant_construct.cpp | 1 |
7 files changed, 26 insertions, 14 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index c872ae2162..02effc2001 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -909,7 +909,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust custom_features += f; } - if (p_path.ends_with(".godot")) { + if (p_path.ends_with(".godot") || p_path.ends_with("override.cfg")) { return _save_settings_text(p_path, props, p_custom, custom_features); } else if (p_path.ends_with(".binary")) { return _save_settings_binary(p_path, props, p_custom, custom_features); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 47c75cfa28..e7a77384da 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -566,7 +566,7 @@ struct _OSCoreBindImg { void _OS::print_all_textures_by_size() { List<_OSCoreBindImg> imgs; - int total = 0; + uint64_t total = 0; { List<Ref<Resource>> rsrc; ResourceCache::get_cached_resources(&rsrc); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 7392e6b9a6..bdbb7766fa 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -76,6 +76,7 @@ public: NetworkProfiler() {} int bandwidth_usage(const Vector<BandwidthFrame> &p_buffer, int p_pointer) { + ERR_FAIL_COND_V(p_buffer.size() == 0, 0); int total_bandwidth = 0; uint32_t timestamp = OS::get_singleton()->get_ticks_msec(); diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 18afdc678e..3863dce0f6 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -96,6 +96,11 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) { ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object."); + if (ssl) { + ERR_FAIL_NULL_MSG(Object::cast_to<StreamPeerSSL>(p_connection.ptr()), + "Connection is not a reference to a valid StreamPeerSSL object."); + } + if (connection == p_connection) { return; } diff --git a/core/os/thread.cpp b/core/os/thread.cpp index aea370787d..f1fcfdf7e1 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -41,9 +41,13 @@ void (*Thread::set_priority_func)(Thread::Priority) = nullptr; void (*Thread::init_func)() = nullptr; void (*Thread::term_func)() = nullptr; -Thread::ID Thread::main_thread_id = 1; -SafeNumeric<Thread::ID> Thread::last_thread_id{ 1 }; -thread_local Thread::ID Thread::caller_id = 1; +uint64_t Thread::_thread_id_hash(const std::thread::id &p_t) { + static std::hash<std::thread::id> hasher; + return hasher(p_t); +} + +Thread::ID Thread::main_thread_id = _thread_id_hash(std::this_thread::get_id()); +thread_local Thread::ID Thread::caller_id = _thread_id_hash(std::this_thread::get_id()); void Thread::_set_platform_funcs( Error (*p_set_name_func)(const String &), @@ -57,7 +61,7 @@ void Thread::_set_platform_funcs( } void Thread::callback(Thread *p_self, const Settings &p_settings, Callback p_callback, void *p_userdata) { - Thread::caller_id = p_self->id; + Thread::caller_id = _thread_id_hash(p_self->thread.get_id()); if (set_priority_func) { set_priority_func(p_settings.priority); } @@ -73,7 +77,7 @@ void Thread::callback(Thread *p_self, const Settings &p_settings, Callback p_cal } void Thread::start(Thread::Callback p_callback, void *p_user, const Settings &p_settings) { - if (id != 0) { + if (id != _thread_id_hash(std::thread::id())) { #ifdef DEBUG_ENABLED WARN_PRINT("A Thread object has been re-started without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread."); #endif @@ -81,22 +85,22 @@ void Thread::start(Thread::Callback p_callback, void *p_user, const Settings &p_ std::thread empty_thread; thread.swap(empty_thread); } - id = last_thread_id.increment(); std::thread new_thread(&Thread::callback, this, p_settings, p_callback, p_user); thread.swap(new_thread); + id = _thread_id_hash(thread.get_id()); } bool Thread::is_started() const { - return id != 0; + return id != _thread_id_hash(std::thread::id()); } void Thread::wait_to_finish() { - if (id != 0) { + if (id != _thread_id_hash(std::thread::id())) { ERR_FAIL_COND_MSG(id == get_caller_id(), "A Thread can't wait for itself to finish."); thread.join(); std::thread empty_thread; thread.swap(empty_thread); - id = 0; + id = _thread_id_hash(std::thread::id()); } } @@ -109,7 +113,7 @@ Error Thread::set_name(const String &p_name) { } Thread::~Thread() { - if (id != 0) { + if (id != _thread_id_hash(std::thread::id())) { #ifdef DEBUG_ENABLED WARN_PRINT("A Thread object has been destroyed without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread."); #endif diff --git a/core/os/thread.h b/core/os/thread.h index 76f5be182e..599585051f 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -62,9 +62,10 @@ private: friend class Main; static ID main_thread_id; - static SafeNumeric<Thread::ID> last_thread_id; - ID id = 0; + static uint64_t _thread_id_hash(const std::thread::id &p_t); + + ID id = _thread_id_hash(std::thread::id()); static thread_local ID caller_id; std::thread thread; diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp index 52f9f6060e..f0c9e52b46 100644 --- a/core/variant/variant_construct.cpp +++ b/core/variant/variant_construct.cpp @@ -773,6 +773,7 @@ void Variant::_unregister_variant_constructors() { } void Variant::construct(Variant::Type p_type, Variant &base, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { + ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); uint32_t s = construct_data[p_type].size(); for (uint32_t i = 0; i < s; i++) { int argc = construct_data[p_type][i].argument_count; |