diff options
Diffstat (limited to 'core/reference.cpp')
| -rw-r--r-- | core/reference.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/core/reference.cpp b/core/reference.cpp index 90bafd0a9..69e053cc1 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "reference.h" - +#include "script_language.h" bool Reference::init_ref() { @@ -54,9 +54,9 @@ bool Reference::init_ref() { void Reference::_bind_methods() { - ObjectTypeDB::bind_method(_MD("init_ref"),&Reference::init_ref); - ObjectTypeDB::bind_method(_MD("reference"),&Reference::reference); - ObjectTypeDB::bind_method(_MD("unreference"),&Reference::unreference); + ClassDB::bind_method(_MD("init_ref"),&Reference::init_ref); + ClassDB::bind_method(_MD("reference"),&Reference::reference); + ClassDB::bind_method(_MD("unreference"),&Reference::unreference); } int Reference::reference_get_count() const { @@ -66,11 +66,21 @@ int Reference::reference_get_count() const { void Reference::reference(){ refcount.ref(); + if (get_script_instance()) { + get_script_instance()->refcount_incremented(); + } } bool Reference::unreference(){ - return refcount.unref(); + bool die = refcount.unref(); + + if (get_script_instance()) { + die = die && get_script_instance()->refcount_decremented(); + } + + return die; + } Reference::Reference() { @@ -116,7 +126,7 @@ WeakRef::WeakRef() { void WeakRef::_bind_methods() { - ObjectTypeDB::bind_method(_MD("get_ref:Object"),&WeakRef::get_ref); + ClassDB::bind_method(_MD("get_ref:Object"),&WeakRef::get_ref); } #if 0 |
