Fix use count for deleted, reference counted objects.

Remove inconsitency of returning 0 or ~0. If the object
has been deleted there are no more references, so always
return 0.
This commit is contained in:
Thomas Geymayer
2014-05-08 01:42:25 +02:00
parent 9975c751a7
commit b2c3a90adf
2 changed files with 6 additions and 6 deletions

View File

@@ -42,11 +42,11 @@ public:
{ return *this; }
static unsigned get(const SGReferenced* ref)
{ if (ref) return ++(ref->_refcount); else return ~0u; }
{ if (ref) return ++(ref->_refcount); else return 0; }
static unsigned put(const SGReferenced* ref)
{ if (ref) return --(ref->_refcount); else return ~0u; }
{ if (ref) return --(ref->_refcount); else return 0; }
static unsigned count(const SGReferenced* ref)
{ if (ref) return ref->_refcount; else return ~0u; }
{ if (ref) return ref->_refcount; else return 0; }
static bool shared(const SGReferenced* ref)
{ if (ref) return 1u < ref->_refcount; else return false; }

View File

@@ -71,11 +71,11 @@ public:
/// The usual operations on weak pointers.
/// The interface should stay the same then what we have in Referenced.
static unsigned get(const SGWeakReferenced* ref)
{ if (ref) return ++(ref->mWeakData->mRefcount); else return 0u; }
{ if (ref) return ++(ref->mWeakData->mRefcount); else return 0; }
static unsigned put(const SGWeakReferenced* ref)
{ if (ref) return --(ref->mWeakData->mRefcount); else return ~0u; }
{ if (ref) return --(ref->mWeakData->mRefcount); else return 0; }
static unsigned count(const SGWeakReferenced* ref)
{ if (ref) return ref->mWeakData->mRefcount; else return 0u; }
{ if (ref) return ref->mWeakData->mRefcount; else return 0; }
private:
/// Support for weak references, not increasing the reference count