diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-11-29 00:19:47 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-11-30 13:11:16 -0300 |
commit | 0e2de944d5ddfce144a824280e08febbc8a1271a (patch) | |
tree | 3e01ab30d86a5fac291bc715f6faf6f26df6970d /libshiboken/bindingmanager.cpp | |
parent | 22fb6d89c445174e77afe698d247c72d05e1576a (diff) |
Wrapper invalidation method recursively updates children objects status.
BindingManager::invalidateWrapper checks if the object to be invalidated
carries any children objects and recursively invalidates them.
Shiboken::destroyParentInfo function was refactored to call the new
recursive wrapper invalidator and then call a helper function that
only destroy the parent information.
The invalidate parent test was updated.
Diffstat (limited to 'libshiboken/bindingmanager.cpp')
-rw-r--r-- | libshiboken/bindingmanager.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp index 4774cb2d8..3610e2907 100644 --- a/libshiboken/bindingmanager.cpp +++ b/libshiboken/bindingmanager.cpp @@ -131,11 +131,19 @@ PyObject* BindingManager::getOverride(const void* cptr, const char* methodName) return 0; } -void BindingManager::invalidateWrapper(PyObject* wrapper) +void BindingManager::invalidateWrapper(PyBaseWrapper* wrapper) { + if (!PyBaseWrapper_validCppObject(wrapper)) + return; PyBaseWrapper_setValidCppObject(wrapper, false); PyBaseWrapper_setOwnership(wrapper, false); - releaseWrapper(wrapper); + // If it is a parent invalidate all children. + if (PyBaseWrapper_hasParentInfo(wrapper)) { + ShiboChildrenList::iterator it = wrapper->parentInfo->children.begin(); + for (; it != wrapper->parentInfo->children.end(); ++it) + invalidateWrapper(*it); + } + releaseWrapper(reinterpret_cast<PyObject*>(wrapper)); } void BindingManager::invalidateWrapper(const void* cptr) |