diff options
| author | 2011-06-06 15:21:44 -0700 | |
|---|---|---|
| committer | 2011-06-06 15:21:44 -0700 | |
| commit | c1cbf4525b4d12b6cb7908072d36c8f6ca819f5b (patch) | |
| tree | ce173c0b5701869e56fb967aa76185b4ab592131 /libs/utils/RefBase.cpp | |
| parent | e9d32283e4eca1ee27218ed66f754a694678ac6d (diff) | |
| parent | 24855c09173a6caaec7dcedd0c2d7ce15121d39b (diff) | |
am 24855c09: merge various SF fixes from gingerbread to honeycomb-mr2 (DO NOT MERGE)
* commit '24855c09173a6caaec7dcedd0c2d7ce15121d39b':
merge various SF fixes from gingerbread to honeycomb-mr2 (DO NOT MERGE)
Diffstat (limited to 'libs/utils/RefBase.cpp')
| -rw-r--r-- | libs/utils/RefBase.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp index bb6c1255f38a..7de263326a17 100644 --- a/libs/utils/RefBase.cpp +++ b/libs/utils/RefBase.cpp @@ -345,6 +345,10 @@ void RefBase::incStrong(const void* id) const const_cast<RefBase*>(this)->onFirstRef(); } +void RefBase::destroy() const { + delete this; +} + void RefBase::decStrong(const void* id) const { weakref_impl* const refs = mRefs; @@ -357,7 +361,7 @@ void RefBase::decStrong(const void* id) const if (c == 1) { const_cast<RefBase*>(this)->onLastStrongRef(id); if ((refs->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { - delete this; + destroy(); } } refs->decWeak(id); @@ -415,7 +419,8 @@ void RefBase::weakref_type::decWeak(const void* id) if ((impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { if (impl->mStrong == INITIAL_STRONG_VALUE) - delete impl->mBase; + if (impl->mBase) + impl->mBase->destroy(); else { // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase); delete impl; @@ -423,7 +428,8 @@ void RefBase::weakref_type::decWeak(const void* id) } else { impl->mBase->onLastWeakRef(id); if ((impl->mFlags&OBJECT_LIFETIME_FOREVER) != OBJECT_LIFETIME_FOREVER) { - delete impl->mBase; + if (impl->mBase) + impl->mBase->destroy(); } } } |