diff options
author | 2011-08-18 18:01:33 -0700 | |
---|---|---|
committer | 2011-08-18 18:01:33 -0700 | |
commit | 777ec2662ef5ee8b0a501e0b8a9b2d7a2b84ffe7 (patch) | |
tree | d1c4914169163c551f1eee01081528d29aee5aa0 /libs/rs/rsObjectBase.cpp | |
parent | 85deb781658e870556c305c523fa7f2bf679efe3 (diff) |
Fix issue with freeing allocation with circular references.
Change-Id: I45871c20a192815eafee77f95e17a025f6dcf9d1
Diffstat (limited to 'libs/rs/rsObjectBase.cpp')
-rw-r--r-- | libs/rs/rsObjectBase.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp index f428f9486d8d..f5ced26e657c 100644 --- a/libs/rs/rsObjectBase.cpp +++ b/libs/rs/rsObjectBase.cpp @@ -81,6 +81,10 @@ void ObjectBase::incSysRef() const { void ObjectBase::preDestroy() const { } +bool ObjectBase::freeChildren() { + return false; +} + bool ObjectBase::checkDelete(const ObjectBase *ref) { if (!ref) { return false; @@ -217,6 +221,28 @@ void ObjectBase::zeroAllUserRef(Context *rsc) { } } +void ObjectBase::freeAllChildren(Context *rsc) { + if (rsc->props.mLogObjects) { + LOGV("Forcing release of all child objects."); + } + + // This operation can be slow, only to be called during context cleanup. + ObjectBase * o = (ObjectBase *)rsc->mObjHead; + while (o) { + if (o->freeChildren()) { + // deleted ref to self and possibly others, restart from head. + o = (ObjectBase *)rsc->mObjHead; + } else { + o = (ObjectBase *)o->mNext; + } + } + + if (rsc->props.mLogObjects) { + LOGV("Objects remaining."); + dumpAll(rsc); + } +} + void ObjectBase::dumpAll(Context *rsc) { asyncLock(); |