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-25 13:14:10 +0000
commit10263f42de0d2d1fb731deb4213b76fa6c0acd0f (patch)
treec5431517ab811b1c5b1a9d2255d95d5618ae9340
parentd07e6b891e69c9ce4bed9e91c917d81d0d8a6ae1 (diff)
downloadqttools-10263f42de0d2d1fb731deb4213b76fa6c0acd0f.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>
-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;
}