diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-06-17 18:10:21 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:27 -0300 |
commit | 88a84ee6ae8cd12b2527576505f16774c9c542c1 (patch) | |
tree | 64449426c1b79c4647c9f94f09543d7eda4f046b /libshiboken | |
parent | c3eb8bb198b7cbc43236b1edbf7afbf096d8b8f6 (diff) |
Fix refleak during the parent c++ object destruction.
Fixes bug #893.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/basewrapper.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index 79bd9bd5e..9552031ff 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -960,6 +960,11 @@ void removeParent(SbkObject* child, bool giveOwnershipBack, bool keepReference) { ParentInfo* pInfo = child->d->parentInfo; if (!pInfo || !pInfo->parent) { + if (pInfo && pInfo->hasWrapperRef) { + pInfo->hasWrapperRef = false; + delete pInfo; + child->d->parentInfo = 0; + } return; } ChildrenList& oldBrothers = pInfo->parent->d->parentInfo->children; @@ -973,8 +978,15 @@ void removeParent(SbkObject* child, bool giveOwnershipBack, bool keepReference) pInfo->parent = 0; // This will keep the wrapper reference, will wait for wrapper destruction to remove that - if (keepReference && child->d->containsCppWrapper) + if (keepReference && + child->d->containsCppWrapper) { + //If have already a extra ref remove this one + if (pInfo->hasWrapperRef) + Py_CLEAR(child); + else + pInfo->hasWrapperRef = true; return; + } // Transfer ownership back to Python child->d->hasOwnership = giveOwnershipBack; |