From 9347f24516dee4da268f8a94d130d830eccd5558 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Thu, 21 May 2026 14:57:36 -0400 Subject: [PATCH] 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. --- src/gui/MappingListModel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/MappingListModel.cpp b/src/gui/MappingListModel.cpp index 1e5de25..c4ae06f 100644 --- a/src/gui/MappingListModel.cpp +++ b/src/gui/MappingListModel.cpp @@ -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)