From 51c411c7ad46ea25565058ac9e08ae1528b5ba85 Mon Sep 17 00:00:00 2001 From: rune-scape Date: Wed, 28 Sep 2022 23:04:22 -0700 Subject: Fix unset `ObjectID` with validated `get_object()` call Fixes unset `ObjectID` in variant when calling a validated builtin method returning an `Object *`. --- core/variant/variant_internal.h | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'core/variant') diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index 874a183d29..7ae2368fe4 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -1047,7 +1047,7 @@ struct VariantInternalAccessor { template <> struct VariantInternalAccessor { static _FORCE_INLINE_ Object *get(const Variant *v) { return const_cast(*VariantInternal::get_object(v)); } - static _FORCE_INLINE_ void set(Variant *v, const Object *p_value) { *VariantInternal::get_object(v) = const_cast(p_value); } + static _FORCE_INLINE_ void set(Variant *v, const Object *p_value) { VariantInternal::object_assign(v, p_value); } }; template <> @@ -1532,27 +1532,4 @@ struct VariantTypeConstructor { } }; -template <> -struct VariantTypeConstructor { - _FORCE_INLINE_ static void variant_from_type(void *p_variant, void *p_value) { - Variant *variant = reinterpret_cast(p_variant); - VariantInitializer::init(variant); - Object *object = *(reinterpret_cast(p_value)); - if (object) { - if (object->is_ref_counted()) { - if (!VariantInternal::initialize_ref(object)) { - return; - } - } - VariantInternalAccessor::set(variant, object); - VariantInternalAccessor::set(variant, object->get_instance_id()); - } - } - - _FORCE_INLINE_ static void type_from_variant(void *p_value, void *p_variant) { - Object **value = reinterpret_cast(p_value); - *value = VariantInternalAccessor::get(reinterpret_cast(p_variant)); - } -}; - #endif // VARIANT_INTERNAL_H -- cgit v1.2.3