Fix leaks caused by implicitly called copy constructors

pull/355/head
sheepandshepherd 2019-12-04 03:27:39 +01:00
parent 123d9f0e92
commit 95feb486c9
1 changed files with 33 additions and 22 deletions

View File

@ -205,8 +205,9 @@ Variant::operator double() const {
return godot::api->godot_variant_as_real(&_godot_variant); return godot::api->godot_variant_as_real(&_godot_variant);
} }
Variant::operator String() const { Variant::operator String() const {
godot_string s = godot::api->godot_variant_as_string(&_godot_variant); String ret;
return *(String *)&s; *(godot_string *)&ret = godot::api->godot_variant_as_string(&_godot_variant);
return ret;
} }
Variant::operator Vector2() const { Variant::operator Vector2() const {
godot_vector2 s = godot::api->godot_variant_as_vector2(&_godot_variant); godot_vector2 s = godot::api->godot_variant_as_vector2(&_godot_variant);
@ -250,8 +251,9 @@ Variant::operator Color() const {
return *(Color *)&s; return *(Color *)&s;
} }
Variant::operator NodePath() const { Variant::operator NodePath() const {
godot_node_path s = godot::api->godot_variant_as_node_path(&_godot_variant); NodePath ret;
return *(NodePath *)&s; *(godot_node_path *)&ret = godot::api->godot_variant_as_node_path(&_godot_variant);
return ret;
} }
Variant::operator RID() const { Variant::operator RID() const {
godot_rid s = godot::api->godot_variant_as_rid(&_godot_variant); godot_rid s = godot::api->godot_variant_as_rid(&_godot_variant);
@ -259,42 +261,51 @@ Variant::operator RID() const {
} }
Variant::operator Dictionary() const { Variant::operator Dictionary() const {
godot_dictionary d = godot::api->godot_variant_as_dictionary(&_godot_variant); Dictionary ret;
return *(Dictionary *)&d; *(godot_dictionary *)&ret = godot::api->godot_variant_as_dictionary(&_godot_variant);
return ret;
} }
Variant::operator Array() const { Variant::operator Array() const {
godot_array s = godot::api->godot_variant_as_array(&_godot_variant); Array ret;
return *(Array *)&s; *(godot_array *)&ret = godot::api->godot_variant_as_array(&_godot_variant);
return ret;
} }
Variant::operator PoolByteArray() const { Variant::operator PoolByteArray() const {
godot_pool_byte_array s = godot::api->godot_variant_as_pool_byte_array(&_godot_variant); PoolByteArray ret;
return *(PoolByteArray *)&s; *(godot_pool_byte_array *)&ret = godot::api->godot_variant_as_pool_byte_array(&_godot_variant);
return ret;
} }
Variant::operator PoolIntArray() const { Variant::operator PoolIntArray() const {
godot_pool_int_array s = godot::api->godot_variant_as_pool_int_array(&_godot_variant); PoolIntArray ret;
return *(PoolIntArray *)&s; *(godot_pool_int_array *)&ret = godot::api->godot_variant_as_pool_int_array(&_godot_variant);
return ret;
} }
Variant::operator PoolRealArray() const { Variant::operator PoolRealArray() const {
godot_pool_real_array s = godot::api->godot_variant_as_pool_real_array(&_godot_variant); PoolRealArray ret;
return *(PoolRealArray *)&s; *(godot_pool_real_array *)&ret = godot::api->godot_variant_as_pool_real_array(&_godot_variant);
return ret;
} }
Variant::operator PoolStringArray() const { Variant::operator PoolStringArray() const {
godot_pool_string_array s = godot::api->godot_variant_as_pool_string_array(&_godot_variant); PoolStringArray ret;
return *(PoolStringArray *)&s; *(godot_pool_string_array *)&ret = godot::api->godot_variant_as_pool_string_array(&_godot_variant);
return ret;
} }
Variant::operator PoolVector2Array() const { Variant::operator PoolVector2Array() const {
godot_pool_vector2_array s = godot::api->godot_variant_as_pool_vector2_array(&_godot_variant); PoolVector2Array ret;
return *(PoolVector2Array *)&s; *(godot_pool_vector2_array *)&ret = godot::api->godot_variant_as_pool_vector2_array(&_godot_variant);
return ret;
} }
Variant::operator PoolVector3Array() const { Variant::operator PoolVector3Array() const {
godot_pool_vector3_array s = godot::api->godot_variant_as_pool_vector3_array(&_godot_variant); PoolVector3Array ret;
return *(PoolVector3Array *)&s; *(godot_pool_vector3_array *)&ret = godot::api->godot_variant_as_pool_vector3_array(&_godot_variant);
return ret;
} }
Variant::operator PoolColorArray() const { Variant::operator PoolColorArray() const {
godot_pool_color_array s = godot::api->godot_variant_as_pool_color_array(&_godot_variant); PoolColorArray ret;
return *(PoolColorArray *)&s; *(godot_pool_color_array *)&ret = godot::api->godot_variant_as_pool_color_array(&_godot_variant);
return ret;
} }
Variant::operator godot_object *() const { Variant::operator godot_object *() const {
return godot::api->godot_variant_as_object(&_godot_variant); return godot::api->godot_variant_as_object(&_godot_variant);