diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-06-06 16:40:10 +0200 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-06-06 16:40:10 +0200 |
commit | 41aa71f8c366feb7949ad30c3459ce9158c9565b (patch) | |
tree | 706d2e70a0b14d0b62c921ce089c74ec71225726 | |
parent | 21d526e5e5b1e5d8b6be4db05a704c2c2e7837a9 (diff) | |
download | redot-cpp-41aa71f8c366feb7949ad30c3459ce9158c9565b.tar.gz |
Fix sharing of typed arrays from constructor
-rw-r--r-- | include/godot_cpp/variant/typed_array.hpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/include/godot_cpp/variant/typed_array.hpp b/include/godot_cpp/variant/typed_array.hpp index 47b7410..ce20139 100644 --- a/include/godot_cpp/variant/typed_array.hpp +++ b/include/godot_cpp/variant/typed_array.hpp @@ -44,10 +44,15 @@ public: _ref(p_array); } _FORCE_INLINE_ TypedArray(const Variant &p_variant) : - Array(p_variant.operator Array(), Variant::OBJECT, T::get_class_static(), Variant()) { + TypedArray(Array(p_variant)) { } - _FORCE_INLINE_ TypedArray(const Array &p_array) : - Array(p_array, Variant::OBJECT, T::get_class_static(), Variant()) { + _FORCE_INLINE_ TypedArray(const Array &p_array) { + set_typed(Variant::OBJECT, T::get_class_static(), Variant()); + if (is_same_typed(p_array)) { + _ref(p_array); + } else { + assign(p_array); + } } _FORCE_INLINE_ TypedArray() { set_typed(Variant::OBJECT, T::get_class_static(), Variant()); @@ -65,10 +70,15 @@ public: _ref(p_array); \ } \ _FORCE_INLINE_ TypedArray(const Variant &p_variant) : \ - Array(p_variant.operator Array(), m_variant_type, StringName(), Variant()) { \ + TypedArray(Array(p_variant)) { \ } \ - _FORCE_INLINE_ TypedArray(const Array &p_array) : \ - Array(p_array, m_variant_type, StringName(), Variant()) { \ + _FORCE_INLINE_ TypedArray(const Array &p_array) { \ + set_typed(m_variant_type, StringName(), Variant()); \ + if (is_same_typed(p_array)) { \ + _ref(p_array); \ + } else { \ + assign(p_array); \ + } \ } \ _FORCE_INLINE_ TypedArray() { \ set_typed(m_variant_type, StringName(), Variant()); \ |