summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2018-10-25 13:32:08 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2018-10-29 10:12:31 +0000
commit6eb145aa634a2594424e271b9453610072266786 (patch)
tree635e43376eeb4e95439593bfb713006aecd5eef7
parent03aa69af7695870772ee9126462e44f7de4f1ed9 (diff)
downloadqttools-6eb145aa634a2594424e271b9453610072266786.tar.gz
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 <Friedemann.Kleint@qt.io> (cherry picked from commit 10263f42de0d2d1fb731deb4213b76fa6c0acd0f)
-rw-r--r--src/assistant/assistant/preferencesdialog.cpp1
1 files changed, 1 insertions, 0 deletions
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<int> PreferencesDialog::currentRegisteredDocsSelection() const
QList<int> 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;
}