Fix incorrect usage of list iterators

The problem was that we erased an iterator from the list and then
incremented it. This can lead to problems (namely, random crashes) if
the iterator pointed to the last list element.

Thanks to Sandro Mani for testing the patch!

BUG: 311246
FIXED-IN: 4.9.5
This commit is contained in:
Frank Reininghaus 2012-12-06 19:43:11 +01:00
parent 5343a18b50
commit 6d0f9ada01

View file

@ -1227,11 +1227,14 @@ void DolphinView::updateViewState()
QSet<int> selectedItems = selectionManager->selectedItems();
for (QList<KUrl>::iterator it = m_selectedUrls.begin(); it != m_selectedUrls.end(); ++it) {
QList<KUrl>::iterator it = m_selectedUrls.begin();
while (it != m_selectedUrls.end()) {
const int index = m_model->index(*it);
if (index >= 0) {
selectedItems.insert(index);
m_selectedUrls.erase(it);
it = m_selectedUrls.erase(it);
} else {
++it;
}
}