Fix #855 - Avoid a crash when there's no model (#856)

* Fix #855 - Avoid a crash when there's no model

* Moved the update id to the AbstactItem class
This commit is contained in:
Alexandre 2021-04-09 10:03:59 -04:00 committed by GitHub
parent 40e6bf0793
commit f5fa60c50c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,14 +47,9 @@ class abstractItem():
if parent:
# add this as a child to the parent, and link to the outlineModel of the parent
parent.appendChild(self)
elif not model:
print("Warning: floating outline item (has no parent or associated Outline model).")
if ID:
self._data[self.enum.ID] = ID
self._model.updateAvailableIDs(ID) # Informs the ID distributor that this ID number has been used
else:
self._data[self.enum.ID] = self._model.requestNewID()
@ -64,6 +59,11 @@ class abstractItem():
def setModel(self, model):
self._model = model
if not self.ID():
self.getUniqueID()
elif model:
# if we are setting a model update it's ID
self._model.updateAvailableIDs(self.ID())
for c in self.children():
c.setModel(model)