From 10263f42de0d2d1fb731deb4213b76fa6c0acd0f Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 25 Oct 2018 13:32:08 +0200 Subject: Assistant: Fix a crash when removing the docs Inside the PreferencesDialog, when the currentRegisteredDocsSelection() returns the unsorted list we may crash inside removeDocumentation(). Please note that we iterate through the currentSelection() list in the reverse order. However, when the values are not sorted there, we may remove items from entries list in a random order. After the first removal the row index may point outside of the list or point to the wrong doc. The fix is to sort the list returned by the currentRegisteredDocsSelection(). In this way we enure that we remove entries in the reverse order and guarantee that values of the currentSelection list matche the indices of the entries list. Fixes: QTBUG-71399 Change-Id: I545f358e1d55e64823ffdaf0ce27a8b97aeedf04 Reviewed-by: Friedemann Kleint --- src/assistant/assistant/preferencesdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/assistant/assistant/preferencesdialog.cpp b/src/assistant/assistant/preferencesdialog.cpp index 4652d0187..28df681c6 100644 --- a/src/assistant/assistant/preferencesdialog.cpp +++ b/src/assistant/assistant/preferencesdialog.cpp @@ -382,6 +382,7 @@ QList PreferencesDialog::currentRegisteredDocsSelection() const QList result; for (const QModelIndex &index : m_ui.registeredDocsListView->selectionModel()->selectedRows()) result.append(m_registereredDocsFilterModel->mapToSource(index).row()); + std::sort(result.begin(), result.end()); return result; } -- cgit v1.2.1