Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.8.x, 5.0.0, 5.6.0 Alpha
-
e6e4456de0506aa9896b687dc858eb9ae03d8917
Description
tst_QFileSystemModel::sort() test creates a couple of files into a temporary directory, then sorts the view by the file size.
This correctly sorts the files, but the entries for the "." and ".." get sorted in an arbitrary order. The root cause seems to be this part from qfilesystemmodel.cpp
QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > values; QHash<QString, QFileSystemNode *>::const_iterator iterator; int i = 0; for(iterator = indexNode->children.begin() ; iterator != indexNode->children.end() ; ++iterator) { if (filtersAcceptsNode(iterator.value())) { values.append(QPair<QFileSystemModelPrivate::QFileSystemNode*, int>((iterator.value()), i)); } else { iterator.value()->isVisible = false; } i++; } QFileSystemModelSorter ms(column); qStableSort(values.begin(), values.end(), ms);
where the items get added to a list in the hash order, then a stable sort is done on them; but the sorter won't enforce any order between "." and ".." (both are very likely to have the same size), therefore their order will be the one picked up by the iterator.
On the contrary, down in the test, a specific order is expected:
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + "." << dirPath + QChar('/') + "..";