From 8561698c9bd2fd91aee81a3ac8fa5a2f7d2351f6 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 19 May 2011 20:41:27 -0700 Subject: [PATCH] Call RefBase::destroy() when OBJECT_LIFETIME_* is not the default Change-Id: Ifb2069e095dba57b7d97e9f2d942fd85fa975f58 --- libs/utils/RefBase.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp index 9f55a7157..dd0052ab9 100644 --- a/libs/utils/RefBase.cpp +++ b/libs/utils/RefBase.cpp @@ -419,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; @@ -427,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(); } } }