From 0de61998e42b368efe90ad07838aea99752447c0 Mon Sep 17 00:00:00 2001 From: Emmanuel Leblond Date: Mon, 15 Jan 2018 23:20:02 +0100 Subject: [PATCH] Improve inheritance system in gdnative pluginscript --- .../pluginscript/pluginscript_instance.cpp | 5 +- .../pluginscript/pluginscript_language.cpp | 1 + .../pluginscript/pluginscript_script.cpp | 49 +++++++++---------- .../pluginscript/pluginscript_script.h | 2 +- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp index 52d112bc930..931ab0bfe42 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.cpp +++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp @@ -84,8 +84,9 @@ Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p godot_variant ret = _desc->call_method( _data, (godot_string_name *)&p_method, (const godot_variant **)p_args, p_argcount, (godot_variant_call_error *)&r_error); - Variant *var_ret = (Variant *)&ret; - return *var_ret; + Variant var_ret = *(Variant *)&ret; + godot_variant_destroy(&ret); + return var_ret; } #if 0 // TODO: Don't rely on default implementations provided by ScriptInstance ? diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 8101ebc6f3d..8018178bd54 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -103,6 +103,7 @@ Ref