Fix initialization of objects in VariantInternal
This commit is contained in:
parent
2a9c4a59df
commit
a685535ad5
|
@ -104,7 +104,7 @@ public:
|
||||||
init_color_array(v);
|
init_color_array(v);
|
||||||
break;
|
break;
|
||||||
case Variant::OBJECT:
|
case Variant::OBJECT:
|
||||||
object_assign_null(v);
|
init_object(v);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -280,6 +280,10 @@ public:
|
||||||
v->_data.packed_array = Variant::PackedArrayRef<Color>::create(Vector<Color>());
|
v->_data.packed_array = Variant::PackedArrayRef<Color>::create(Vector<Color>());
|
||||||
v->type = Variant::PACKED_COLOR_ARRAY;
|
v->type = Variant::PACKED_COLOR_ARRAY;
|
||||||
}
|
}
|
||||||
|
_FORCE_INLINE_ static void init_object(Variant *v) {
|
||||||
|
object_assign_null(v);
|
||||||
|
v->type = Variant::OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ static void clear(Variant *v) {
|
_FORCE_INLINE_ static void clear(Variant *v) {
|
||||||
v->clear();
|
v->clear();
|
||||||
|
@ -1173,7 +1177,7 @@ struct VariantInitializer<PackedColorArray> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct VariantInitializer<Object *> {
|
struct VariantInitializer<Object *> {
|
||||||
static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::object_assign_null(v); }
|
static _FORCE_INLINE_ void init(Variant *v) { VariantInternal::init_object(v); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -1405,4 +1409,22 @@ struct VariantTypeConstructor {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct VariantTypeConstructor<Object *> {
|
||||||
|
_FORCE_INLINE_ static void variant_from_type(void *p_variant, void *p_value) {
|
||||||
|
Variant *variant = reinterpret_cast<Variant *>(p_variant);
|
||||||
|
VariantInitializer<Object *>::init(variant);
|
||||||
|
Object *value = *(reinterpret_cast<Object **>(p_value));
|
||||||
|
if (value) {
|
||||||
|
VariantInternalAccessor<Object *>::set(variant, value);
|
||||||
|
VariantInternalAccessor<ObjectID>::set(variant, value->get_instance_id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_FORCE_INLINE_ static void type_from_variant(void *p_value, void *p_variant) {
|
||||||
|
Object **value = reinterpret_cast<Object **>(p_value);
|
||||||
|
*value = VariantInternalAccessor<Object *>::get(reinterpret_cast<Variant *>(p_variant));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#endif // VARIANT_INTERNAL_H
|
#endif // VARIANT_INTERNAL_H
|
||||||
|
|
|
@ -174,7 +174,7 @@ void (*type_init_function_table[])(Variant *) = {
|
||||||
&VariantInitializer<StringName>::init, // STRING_NAME.
|
&VariantInitializer<StringName>::init, // STRING_NAME.
|
||||||
&VariantInitializer<NodePath>::init, // NODE_PATH.
|
&VariantInitializer<NodePath>::init, // NODE_PATH.
|
||||||
&VariantInitializer<RID>::init, // RID.
|
&VariantInitializer<RID>::init, // RID.
|
||||||
&VariantTypeAdjust<Object *>::adjust, // OBJECT.
|
&VariantInitializer<Object *>::init, // OBJECT.
|
||||||
&VariantInitializer<Callable>::init, // CALLABLE.
|
&VariantInitializer<Callable>::init, // CALLABLE.
|
||||||
&VariantInitializer<Signal>::init, // SIGNAL.
|
&VariantInitializer<Signal>::init, // SIGNAL.
|
||||||
&VariantInitializer<Dictionary>::init, // DICTIONARY.
|
&VariantInitializer<Dictionary>::init, // DICTIONARY.
|
||||||
|
|
Loading…
Reference in New Issue