Fix crash in MappingListModel::clear() on empty list

The previous implementation used end()-1 on a potentially empty QList,
causing an invalid iterator and a Qt assertion failure. The iterator
was also invalidated after each erase() call, making the loop UB.

Replace with the standard Qt model reset pattern.
This commit is contained in:
Alexandre Quessy
2026-05-21 14:57:36 -04:00
parent aff0e70af6
commit 9347f24516
+3 -4
View File
@@ -242,10 +242,9 @@ void MappingListModel::updateModel()
void MappingListModel::clear()
{
for (auto it = mappingList.end() - 1; it >= mappingList.begin(); --it) {
mappingList.erase(it);
updateModel();
}
beginResetModel();
mappingList.clear();
endResetModel();
}
QModelIndex MappingListModel::getIndexFromRow(int row)