From 4eb6bf32792b37d97f7d0d50bf2669b04fa77583 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 12 Jul 2009 13:04:49 +0200 Subject: python/sourcelist.cc: Fix deletion of MetaIndex objects returned in SourceList.list. First of all, make the objects mortal by decreasing their refcount after adding them to the list. Secondly, make the objects owned by SourceList and thirdly, set NoDelete on them, because they are managed by SourceList. --- python/sourcelist.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'python/sourcelist.cc') diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 0820d5bf..aceb19ad 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -90,9 +90,12 @@ static PyObject *PkgSourceListGetList(PyObject *Self,void*) for (vector::const_iterator I = list->begin(); I != list->end(); I++) { - PyObject *Obj; - Obj = CppPyObject_NEW(&MetaIndexType,*I); + CppOwnedPyObject *Obj; + Obj = CppOwnedPyObject_NEW(Self, &MetaIndexType,*I); + // Never delete metaIndex*, they are managed by the pkgSourceList. + Obj->NoDelete = true; PyList_Append(List,Obj); + Py_DECREF(Obj); } return List; } -- cgit v1.2.3