fix: some crashes
This commit is contained in:
parent
7e4ba0b1a0
commit
f000ad4484
@ -60,8 +60,10 @@ class Collection(Generic[T]):
|
||||
self._contains_ids.remove(__object.id)
|
||||
|
||||
for name, value in self._id_to_index_values[__object.id]:
|
||||
del self._indexed_values[name]
|
||||
del self._indexed_to_objects[value]
|
||||
if name in self._indexed_values:
|
||||
del self._indexed_values[name]
|
||||
if value in self._indexed_to_objects:
|
||||
del self._indexed_to_objects[value]
|
||||
|
||||
del self._id_to_index_values[__object.id]
|
||||
|
||||
@ -228,7 +230,6 @@ class Collection(Generic[T]):
|
||||
else:
|
||||
# merge only if the two objects are not the same
|
||||
if existing_object.id == __object.id:
|
||||
exit()
|
||||
return
|
||||
|
||||
append_to._unmap_element(existing_object)
|
||||
@ -282,7 +283,7 @@ class Collection(Generic[T]):
|
||||
yield from c.__iter__(finished_ids=finished_ids)
|
||||
|
||||
def __merge__(self, __other: Collection, override: bool = False):
|
||||
self.extend(__other.__iter__())
|
||||
self.extend(__other)
|
||||
|
||||
def __getitem__(self, item: int):
|
||||
if item < len(self._data):
|
||||
|
@ -194,17 +194,23 @@ class OuterProxy:
|
||||
|
||||
if a._inner is b._inner:
|
||||
return
|
||||
|
||||
|
||||
# switch instances if more efficient
|
||||
if len(b._inner._refers_to_instances) > len(a._inner._refers_to_instances):
|
||||
a, b = b, a
|
||||
|
||||
a._inner.__merge__(b._inner, override=override)
|
||||
for collection, child_collection in b._inner._is_collection_child.items():
|
||||
collection.children.remove(child_collection)
|
||||
try:
|
||||
collection.children.remove(child_collection)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
for collection, parent_collection in b._inner._is_collection_parent.items():
|
||||
collection.parents.remove(parent_collection)
|
||||
try:
|
||||
collection.parents.remove(parent_collection)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
a._inner._refers_to_instances.update(b._inner._refers_to_instances)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user