mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user