mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix out of bounds indices in InputModel
This commit is contained in:
parent
1de4c8dc2e
commit
bcb1617a69
|
@ -120,8 +120,14 @@ QVariant InputModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||
QModelIndex InputModel::index(int row, int column, const QModelIndex& parent) const {
|
||||
if (parent.isValid()) {
|
||||
InputModelItem* p = static_cast<InputModelItem*>(parent.internalPointer());
|
||||
if (row >= m_tree[p->obj].count()) {
|
||||
return QModelIndex();
|
||||
}
|
||||
return createIndex(row, column, const_cast<InputModelItem*>(&m_tree[p->obj][row]));
|
||||
}
|
||||
if (row >= m_topLevelMenus.count()) {
|
||||
return QModelIndex();
|
||||
}
|
||||
return createIndex(row, column, const_cast<InputModelItem*>(&m_topLevelMenus[row]));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue