diff options
Diffstat (limited to 'python/acquire-item.cc')
| -rw-r--r-- | python/acquire-item.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/python/acquire-item.cc b/python/acquire-item.cc index cf0a628e..1fb66080 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -176,13 +176,11 @@ static PyObject *acquireitem_repr(PyObject *Self) static void acquireitem_dealloc(PyObject *self) { + pkgAcquire::Item *item = PyAcquireItem_ToCpp(self); + PyAcquireObject *Owner = (PyAcquireObject *)GetOwner<pkgAcquire::Item*>(self); + PyAcquireItems item_struct = Owner->items[item]; // TODO: Unregister the object in the owner. if (!((CppOwnedPyObject<pkgAcquire::Item*>*)self)->NoDelete) { - pkgAcquire::Item *item = PyAcquireItem_ToCpp(self); - PyAcquireObject *Owner = (PyAcquireObject *)GetOwner<pkgAcquire::Item*>(self); - - PyAcquireItems item_struct = Owner->items[item]; - if (item_struct.file != 0 && item_struct.file != self) item_struct.file->Object = 0; if (item_struct.item != 0 && item_struct.item != self) { @@ -195,6 +193,12 @@ static void acquireitem_dealloc(PyObject *self) } Owner->items.erase(item); } + else { + if (item_struct.file == self) + item_struct.file = 0; + if (item_struct.item == self) + item_struct.item = 0; + } CppOwnedDeallocPtr<pkgAcquire::Item*>(self); } |
