Skip to content

Commit

Permalink
gui/models: handle Qt calling DictSyncTreeSepModel.index with garbage…
Browse files Browse the repository at this point in the history
… inputs. Closes #388
sbourdeauducq committed Apr 11, 2016
1 parent e7d448e commit 9361900
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions artiq/gui/models.py
Original file line number Diff line number Diff line change
@@ -252,13 +252,24 @@ def headerData(self, col, orientation, role):
return None

def index(self, row, column, parent):
if column >= len(self.headers):
return QtCore.QModelIndex()
if parent.isValid():
parent_item = parent.internalPointer()
return self.createIndex(row, column,
parent_item.children_by_row[row])
try:
child = parent_item.children_by_row[row]
except IndexError:
# This can happen when the last row is selected
# and then deleted; Qt will attempt to select
# the non-existent next one.
return QtCore.QModelIndex()
return self.createIndex(row, column, child)
else:
return self.createIndex(row, column,
self.children_by_row[row])
try:
child = self.children_by_row[row]
except IndexError:
return QtCore.QModelIndex()
return self.createIndex(row, column, child)

def _index_item(self, item):
if item is self:

0 comments on commit 9361900

Please sign in to comment.