Fixed an issue with wrapping new objects into tl::Variants which are returned directly. For these objects, ownership needs to be transferred to the script.

This commit is contained in:
Matthias Koefferlein
2020-12-27 17:09:06 +01:00
parent 992be87812
commit 4ec00fb129
10 changed files with 222 additions and 108 deletions
+11 -1
View File
@@ -2460,8 +2460,18 @@ void Variant::user_destroy ()
void *obj = to_user ();
if (obj) {
user_cls ()->destroy (obj);
m_type = t_nil;
}
reset ();
}
void *Variant::user_take ()
{
tl_assert (is_user ());
void *obj = to_user ();
if (obj) {
m_type = t_nil;
}
return obj;
}
void Variant::user_assign (const tl::Variant &other)
+5
View File
@@ -861,6 +861,11 @@ public:
*/
void user_destroy ();
/**
* @brief Takes the user object and releases it from the variant
*/
void *user_take ();
/**
* @brief Assigns the object stored in other to self
*