summaryrefslogtreecommitdiff
path: root/modules/mono
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2019-02-14 22:54:10 +0100
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2019-02-14 22:54:15 +0100
commitb41a7935925a1f861f6230f8af5d91ef02c5c2d5 (patch)
treea04ed274321b3b04b55b124cef9009cbfa4991d2 /modules/mono
parent325efb60b7b4f7cb4ed11097c8f2e2de973e00d0 (diff)
Fix Godot.Reference marshalling from MonoObject* to Variant
Need to cast Ref<T> to Variant instead of constructing Variant from Object*, otherwise the Variant won't hold a reference.
Diffstat (limited to 'modules/mono')
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 74395de41c..18a49d0d1f 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -698,7 +698,11 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
// GodotObject
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
Object *ptr = unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj));
- return ptr ? Variant(ptr) : Variant();
+ if (ptr != NULL) {
+ Reference *ref = Object::cast_to<Reference>(ptr);
+ return ref ? Variant(Ref<Reference>(ref)) : Variant(ptr);
+ }
+ return Variant();
}
if (CACHED_CLASS(NodePath) == type_class) {