summaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-10-17 17:15:37 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2011-10-18 16:59:51 -0200
commit6a174ec4459a2805524f3b25ca2bfa62efa66496 (patch)
tree6a3a4977090f2802b1fe2ac03cb1d899343060b9 /libshiboken
parentce79f7578e3d057e5a687b47d0d787c36da46cbd (diff)
downloadshiboken-6a174ec4459a2805524f3b25ca2bfa62efa66496.tar.gz
shiboken-6a174ec4459a2805524f3b25ca2bfa62efa66496.tar.xz
shiboken-6a174ec4459a2805524f3b25ca2bfa62efa66496.zip
Don't delete parentInfo when it seens to be useless to avoid crash on garbage collector.
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/basewrapper.cpp18
-rw-r--r--libshiboken/basewrapper_p.h8
2 files changed, 13 insertions, 13 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 26a8cc76..42a04db7 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -366,7 +366,7 @@ void _destroyParentInfo(SbkObject* obj, bool keepReference)
// Mark child as invalid
Shiboken::Object::invalidate(first);
Shiboken::Object::removeParent(first, false, keepReference);
- }
+ }
Shiboken::Object::removeParent(obj, false);
}
}
@@ -1084,11 +1084,10 @@ void removeParent(SbkObject* child, bool giveOwnershipBack, bool keepReference)
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;
// Verify if this child is part of parent list
ChildrenList::iterator iChild = std::find(oldBrothers.begin(), oldBrothers.end(), child);
@@ -1104,7 +1103,7 @@ void removeParent(SbkObject* child, bool giveOwnershipBack, bool keepReference)
child->d->containsCppWrapper) {
//If have already a extra ref remove this one
if (pInfo->hasWrapperRef)
- Py_CLEAR(child);
+ Py_DECREF(child);
else
pInfo->hasWrapperRef = true;
return;
@@ -1113,14 +1112,8 @@ void removeParent(SbkObject* child, bool giveOwnershipBack, bool keepReference)
// Transfer ownership back to Python
child->d->hasOwnership = giveOwnershipBack;
- if (pInfo->children.empty()) {
- // Erase parentInfo data
- delete pInfo;
- child->d->parentInfo = 0;
- }
-
// Remove parent ref
- Py_CLEAR(child);
+ Py_DECREF(child);
}
void setParent(PyObject* parent, PyObject* child)
@@ -1286,8 +1279,7 @@ void clearReferences(SbkObject* self)
RefCountMap::iterator iter;
for (iter = refCountMap.begin(); iter != refCountMap.end(); ++iter)
decRefPyObjectList(iter->second);
- delete self->d->referredObjects;
- self->d->referredObjects = 0;
+ self->d->referredObjects->clear();
}
} // namespace Object
diff --git a/libshiboken/basewrapper_p.h b/libshiboken/basewrapper_p.h
index b672d4c9..8e2c9934 100644
--- a/libshiboken/basewrapper_p.h
+++ b/libshiboken/basewrapper_p.h
@@ -80,6 +80,14 @@ struct SbkObjectPrivate
Shiboken::ParentInfo* parentInfo;
/// Manage reference counting of objects that are referred but not owned.
Shiboken::RefCountMap* referredObjects;
+
+ ~SbkObjectPrivate()
+ {
+ delete parentInfo;
+ parentInfo = 0;
+ delete referredObjects;
+ referredObjects = 0;
+ }
};
/// The type behaviour was not defined yet