From db9874a33cfb35d639b9ddf5347d7c60d5647b9a Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 20 Sep 2011 18:21:12 -0300 Subject: Fixed invalidate function in objects with refereces to other objects. Reviewer: Luciano Wolf Marcelo Lira --- libshiboken/basewrapper.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'libshiboken/basewrapper.cpp') diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index 5431c4149..7527e3bb1 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -869,6 +869,20 @@ void invalidate(SbkObject* self) removeParent(*it, true, true); } } + + // If has ref to other objects invalidate all + if (self->d->referredObjects) { + RefCountMap& refCountMap = *(self->d->referredObjects); + RefCountMap::iterator iter; + for (iter = refCountMap.begin(); iter != refCountMap.end(); ++iter) { + const std::list lst = iter->second; + std::list::const_iterator it = lst.begin(); + while(it != lst.end()) { + invalidate(*it); + ++it; + } + } + } } void makeValid(SbkObject* self) @@ -886,6 +900,21 @@ void makeValid(SbkObject* self) for (; it != self->d->parentInfo->children.end(); ++it) makeValid(*it); } + + // If has ref to other objects make all valid again + if (self->d->referredObjects) { + RefCountMap& refCountMap = *(self->d->referredObjects); + RefCountMap::iterator iter; + for (iter = refCountMap.begin(); iter != refCountMap.end(); ++iter) { + const std::list lst = iter->second; + std::list::const_iterator it = lst.begin(); + while(it != lst.end()) { + if (Shiboken::Object::checkType(*it)) + makeValid(reinterpret_cast(*it)); + ++it; + } + } + } } bool hasParentInfo(SbkObject* pyObj) -- cgit v1.2.3