1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Notify instance binding data api of refcount increment/decrement

This commit is contained in:
Ignacio Etcheverry
2018-02-22 15:34:08 +01:00
parent 79a225ac2a
commit 908a30964a
10 changed files with 129 additions and 23 deletions

View File

@@ -66,8 +66,17 @@ int Reference::reference_get_count() const {
bool Reference::reference() {
bool success = refcount.ref();
if (success && get_script_instance()) {
get_script_instance()->refcount_incremented();
if (success && refcount.get() <= 2 /* higher is not relevant */) {
if (get_script_instance()) {
get_script_instance()->refcount_incremented();
}
if (instance_binding_count > 0) {
for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) {
if (_script_instance_bindings[i]) {
ScriptServer::get_language(i)->refcount_incremented_instance_binding(this);
}
}
}
}
return success;
@@ -77,9 +86,19 @@ bool Reference::unreference() {
bool die = refcount.unref();
if (get_script_instance()) {
bool script_ret = get_script_instance()->refcount_decremented();
die = die && script_ret;
if (refcount.get() <= 1 /* higher is not relevant */) {
if (get_script_instance()) {
bool script_ret = get_script_instance()->refcount_decremented();
die = die && script_ret;
}
if (instance_binding_count > 0) {
for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) {
if (_script_instance_bindings[i]) {
bool script_ret = ScriptServer::get_language(i)->refcount_decremented_instance_binding(this);
die = die && script_ret;
}
}
}
}
return die;