diff options
| author | Frank Reininghaus <[email protected]> | 2014-06-04 21:48:19 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2014-06-04 21:49:02 +0200 |
| commit | 352f6441590a050099ee685b2284d1679f733c97 (patch) | |
| tree | e9547883bc442b94569496931b3e22b5c0689fa7 /src/tests/kfileitemmodeltest.cpp | |
| parent | 96c34cfe650cef24bcfd6cfa6977c3b0ccb77281 (diff) | |
Fix possible crash if a kioslave adds multiple items with the same URL
When opening the URL "man:", there are multiple items with the same
name (for example, _exit is shown twice here). When opening a new tab,
the kioslave reports some items as deleted (I have not quite understood
why). The problem is that it reports some of the duplicate items twice
in the list of deleted items. This confused KFileItemModel and
corrupted the internal data structures, and finally, caused a crash.
The fix is to remove all duplicates from
KItemRangeList::fromSortedContainer(const Container& container).
New unit tests included.
BUG: 335672
REVIEW: 118507
FIXED-IN: 4.13.2
Diffstat (limited to 'src/tests/kfileitemmodeltest.cpp')
| -rw-r--r-- | src/tests/kfileitemmodeltest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index 48e72e83f..c584c5e62 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -95,6 +95,7 @@ private slots: void testRefreshFilteredItems(); void testCollapseFolderWhileLoading(); void testCreateMimeData(); + void testDeleteFileMoreThanOnce(); private: QStringList itemsInModel() const; @@ -1697,6 +1698,27 @@ void KFileItemModelTest::testCollapseFolderWhileLoading() QVERIFY(!m_model->isExpanded(1)); } +void KFileItemModelTest::testDeleteFileMoreThanOnce() +{ + QStringList files; + files << "a.txt" << "b.txt" << "c.txt" << "d.txt"; + m_testDir->createFiles(files); + + m_model->loadDirectory(m_testDir->url()); + QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "d.txt"); + + const KFileItem fileItemB = m_model->fileItem(1); + + // Tell the model that a list of items has been deleted, where "b.txt" appears twice in the list. + KFileItemList list; + list << fileItemB << fileItemB; + m_model->slotItemsDeleted(list); + + QVERIFY(m_model->isConsistent()); + QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "c.txt" << "d.txt"); +} + QStringList KFileItemModelTest::itemsInModel() const { QStringList items; |
