diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h index 7bb15d9eea..5b330fe4ac 100644 --- a/core/object/ref_counted.h +++ b/core/object/ref_counted.h @@ -127,6 +127,15 @@ public: ref(p_from); } + void operator=(Ref &&p_from) { + if (reference == p_from.reference) { + return; + } + unref(); + reference = p_from.reference; + p_from.reference = nullptr; + } + template void operator=(const Ref &p_from) { ref_pointer(Object::cast_to(p_from.ptr())); @@ -159,6 +168,11 @@ public: this->operator=(p_from); } + Ref(Ref &&p_from) { + reference = p_from.reference; + p_from.reference = nullptr; + } + template Ref(const Ref &p_from) { this->operator=(p_from);