diff options
author | Marc Gilleron <marc.gilleron@gmail.com> | 2021-01-07 01:05:12 +0000 |
---|---|---|
committer | Marc Gilleron <marc.gilleron@gmail.com> | 2021-01-07 01:05:12 +0000 |
commit | fb71edd45b2473bf0ac502c777a1850fb564087e (patch) | |
tree | 5d7a48365313cd54a2a763efa85728c36cf7ed86 /include/core/Variant.hpp | |
parent | 43828ebb3931b9117ad57f08cc457e052fdfd631 (diff) | |
download | redot-cpp-fb71edd45b2473bf0ac502c777a1850fb564087e.tar.gz |
Fix container and string leaks
Some functions return a new instance of such containers,
but instead we made a copy of them, without taking ownership of the
original created by the function.
Now we use a specific constructor taking ownership on the godot_* struct.
Diffstat (limited to 'include/core/Variant.hpp')
-rw-r--r-- | include/core/Variant.hpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/core/Variant.hpp b/include/core/Variant.hpp index 5f40013..872a5a4 100644 --- a/include/core/Variant.hpp +++ b/include/core/Variant.hpp @@ -31,6 +31,11 @@ class Array; class Variant { godot_variant _godot_variant; + friend class Array; + inline explicit Variant(godot_variant v) { + _godot_variant = v; + } + public: enum Type { @@ -226,7 +231,9 @@ public: operator NodePath() const; operator RID() const; operator godot_object *() const; - template <typename T> operator T*() const { return static_cast<T*>(T::___get_from_variant(*this)); } + + template <typename T> + operator T *() const { return static_cast<T *>(T::___get_from_variant(*this)); } operator Dictionary() const; operator Array() const; |