From e8d48232277e4cc97eab8cfef0d7cd8f4ba5c887 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 12 Mar 2020 11:27:33 -0400 Subject: [PATCH] Unset parent_model when deleting item in model --- src/backend/models/model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/models/model.py b/src/backend/models/model.py index 628329f2..9e1e01b6 100644 --- a/src/backend/models/model.py +++ b/src/backend/models/model.py @@ -96,9 +96,13 @@ class Model(MutableMapping): def __delitem__(self, key) -> None: with self._write_lock: - item = self._data.pop(key) + item = self._data[key] + item.parent_model = None + del self._data[key] + index = self._sorted_data.index(item) del self._sorted_data[index] + ModelItemDeleted(self.sync_id, index)