aboutsummaryrefslogtreecommitdiff
path: root/core/reference.cpp
diff options
context:
space:
mode:
authorRuslan Mustakov2017-08-19 19:41:11 +0700
committerRuslan Mustakov2017-09-14 19:40:36 +0700
commitf08bc0df7c16a6d12292628ec8cc2e015047c450 (patch)
tree73b9bdaf5441798340bcbddcd96edc2430a9ccd0 /core/reference.cpp
parent9ac940677c9febc5f1c52782a717df61b0224344 (diff)
downloadgodot-f08bc0df7c16a6d12292628ec8cc2e015047c450.tar.gz
godot-f08bc0df7c16a6d12292628ec8cc2e015047c450.tar.zst
godot-f08bc0df7c16a6d12292628ec8cc2e015047c450.zip
Diffstat (limited to 'core/reference.cpp')
-rw-r--r--core/reference.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/core/reference.cpp b/core/reference.cpp
index bb70628cb..7f93922d2 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -33,7 +33,7 @@
bool Reference::init_ref() {
- if (refcount.ref()) {
+ if (reference()) {
// this may fail in the scenario of two threads assigning the pointer for the FIRST TIME
// at the same time, which is never likely to happen (would be crazy to do)
@@ -41,7 +41,7 @@ bool Reference::init_ref() {
if (refcount_init.get() > 0) {
refcount_init.unref();
- refcount.unref(); // first referencing is already 1, so compensate for the ref above
+ unreference(); // first referencing is already 1, so compensate for the ref above
}
return true;
@@ -62,13 +62,16 @@ int Reference::reference_get_count() const {
return refcount.get();
}
-void Reference::reference() {
+bool Reference::reference() {
+ bool success = refcount.ref();
- refcount.ref();
- if (get_script_instance()) {
+ if (success && get_script_instance()) {
get_script_instance()->refcount_incremented();
}
+
+ return success;
}
+
bool Reference::unreference() {
bool die = refcount.unref();