Make the model parent call a little more robust

This commit is contained in:
Veronica Berglyd Olsen
2025-02-16 16:44:08 +01:00
parent 1431944c49
commit 6d9b1f7b36
+1 -1
View File
@@ -328,7 +328,7 @@ class ProjectModel(QAbstractItemModel):
def parent(self, index: QModelIndex) -> QModelIndex:
"""Get the parent model index of another index."""
if index.isValid() and (parent := index.internalPointer().parent()):
if index.isValid() and (node := index.internalPointer()) and (parent := node.parent()):
return self.createIndex(parent.row(), 0, parent)
return QModelIndex()