From 7275dd543df03ca86957c85b8459fbaaba233587 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 7 Nov 2019 01:56:15 +0100 Subject: [PATCH 1/3] Add a reset method to Reference --- core/reference.cpp | 7 +++++++ core/reference.h | 1 + 2 files changed, 8 insertions(+) diff --git a/core/reference.cpp b/core/reference.cpp index 92bbdacd5d93..2dccd951d744 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -52,6 +52,7 @@ void Reference::_bind_methods() { ClassDB::bind_method(D_METHOD("init_ref"), &Reference::init_ref); ClassDB::bind_method(D_METHOD("reference"), &Reference::reference); ClassDB::bind_method(D_METHOD("unreference"), &Reference::unreference); + ClassDB::bind_method(D_METHOD("reset_ref"), &Reference::reset_ref); } int Reference::reference_get_count() const { @@ -102,6 +103,12 @@ bool Reference::unreference() { return die; } +void Reference::reset_ref() { + + refcount.init(); + refcount_init.init(); +} + Reference::Reference() { refcount.init(); diff --git a/core/reference.h b/core/reference.h index b8d00a94ad5e..309727495255 100644 --- a/core/reference.h +++ b/core/reference.h @@ -51,6 +51,7 @@ class Reference : public Object { bool init_ref(); bool reference(); // returns false if refcount is at zero and didn't get increased bool unreference(); + void reset_ref(); int reference_get_count() const; Reference(); From b5fbd222b039b414efee2983a1099b11281ad7db Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 10 Nov 2019 23:33:44 +0100 Subject: [PATCH 2/3] add method to reset reference counters --- core/reference.cpp | 7 +++++++ core/reference.h | 1 + 2 files changed, 8 insertions(+) diff --git a/core/reference.cpp b/core/reference.cpp index 92bbdacd5d93..2dccd951d744 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -52,6 +52,7 @@ void Reference::_bind_methods() { ClassDB::bind_method(D_METHOD("init_ref"), &Reference::init_ref); ClassDB::bind_method(D_METHOD("reference"), &Reference::reference); ClassDB::bind_method(D_METHOD("unreference"), &Reference::unreference); + ClassDB::bind_method(D_METHOD("reset_ref"), &Reference::reset_ref); } int Reference::reference_get_count() const { @@ -102,6 +103,12 @@ bool Reference::unreference() { return die; } +void Reference::reset_ref() { + + refcount.init(); + refcount_init.init(); +} + Reference::Reference() { refcount.init(); diff --git a/core/reference.h b/core/reference.h index b8d00a94ad5e..309727495255 100644 --- a/core/reference.h +++ b/core/reference.h @@ -51,6 +51,7 @@ class Reference : public Object { bool init_ref(); bool reference(); // returns false if refcount is at zero and didn't get increased bool unreference(); + void reset_ref(); int reference_get_count() const; Reference(); From ec7bd38c4e1fd84e5e257cf2348fbeaceeb28adf Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 11 Nov 2019 00:56:27 +0100 Subject: [PATCH 3/3] fix format --- core/reference.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/reference.cpp b/core/reference.cpp index 2dccd951d744..8d3fe59dc63c 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -105,8 +105,8 @@ bool Reference::unreference() { void Reference::reset_ref() { - refcount.init(); - refcount_init.init(); + refcount.init(); + refcount_init.init(); } Reference::Reference() {