diff options
| author | Frank Reininghaus <[email protected]> | 2012-12-06 19:43:11 +0100 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2012-12-06 19:48:59 +0100 |
| commit | a1353a9d48bc8a45516f7d9323c5a9f99194b310 (patch) | |
| tree | 68025724fc925fc725e0bb73bf6167d1024c4544 /src/views/dolphinview.cpp | |
| parent | f19811517a714ae19e8222727eaaa39d65605cd0 (diff) | |
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
Diffstat (limited to 'src/views/dolphinview.cpp')
| -rw-r--r-- | src/views/dolphinview.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 70a739427..0e97c5a2b 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -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; } } |
