diff --git a/core/string/translation_server.h b/core/string/translation_server.h index b7e7107e2ba..a8c927a74dc 100644 --- a/core/string/translation_server.h +++ b/core/string/translation_server.h @@ -77,7 +77,7 @@ class TranslationServer : public Object { (p_locale.variant == variant); } - operator String() const; + explicit operator String() const; Locale(const TranslationServer &p_server, const String &p_locale, bool p_add_defaults); }; diff --git a/core/templates/hashfuncs.h b/core/templates/hashfuncs.h index 05870f77e98..6a228b0cde4 100644 --- a/core/templates/hashfuncs.h +++ b/core/templates/hashfuncs.h @@ -55,6 +55,7 @@ #include "core/templates/pair.h" #include "core/templates/rid.h" #include "core/typedefs.h" +#include "core/variant/callable.h" #ifdef _MSC_VER #include // Needed for `__umulh` below. @@ -342,6 +343,7 @@ struct HashMapHasherDefault { static _FORCE_INLINE_ uint32_t hash(const StringName &p_string_name) { return p_string_name.hash(); } static _FORCE_INLINE_ uint32_t hash(const NodePath &p_path) { return p_path.hash(); } static _FORCE_INLINE_ uint32_t hash(const ObjectID &p_id) { return hash_one_uint64(p_id); } + static _FORCE_INLINE_ uint32_t hash(const Callable &p_callable) { return p_callable.hash(); } static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) { return hash_one_uint64(p_int); } static _FORCE_INLINE_ uint32_t hash(const int64_t p_int) { return hash_one_uint64(uint64_t(p_int)); } diff --git a/core/variant/callable.h b/core/variant/callable.h index 89299c568b5..3c6919e4e12 100644 --- a/core/variant/callable.h +++ b/core/variant/callable.h @@ -123,7 +123,7 @@ public: void operator=(const Callable &p_callable); - operator String() const; + explicit operator String() const; static Callable create(const Variant &p_variant, const StringName &p_method); @@ -190,7 +190,7 @@ public: bool operator!=(const Signal &p_signal) const; bool operator<(const Signal &p_signal) const; - operator String() const; + explicit operator String() const; Error emit(const Variant **p_arguments, int p_argcount) const; Error connect(const Callable &p_callable, uint32_t p_flags = 0); diff --git a/core/variant/method_ptrcall.h b/core/variant/method_ptrcall.h index 40c5f499c1e..639a3d2933e 100644 --- a/core/variant/method_ptrcall.h +++ b/core/variant/method_ptrcall.h @@ -131,7 +131,7 @@ struct PtrToArgStringConvertByReference { // No EncodeT because direct pointer conversion not possible. _FORCE_INLINE_ static void encode(const T &p_vec, void *p_ptr) { String *arr = reinterpret_cast(p_ptr); - *arr = p_vec; + *arr = String(p_vec); } }; diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 5992227331a..b8f004dd998 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1725,11 +1725,11 @@ String Variant::stringify(int recursion_count) const { } case CALLABLE: { const Callable &c = *reinterpret_cast(_data._mem); - return c; + return String(c); } case SIGNAL: { const Signal &s = *reinterpret_cast(_data._mem); - return s; + return String(s); } case RID: { const ::RID &s = *reinterpret_cast(_data._mem);