diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-12-23 22:22:27 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-12-29 10:58:44 +0000 |
commit | c6177dcccf73427b75b1f1efe80317b7f4fdddc9 (patch) | |
tree | 279b7da27682e72ada858c8d8d44d99ed13b8dbd /src/corelib/mimetypes | |
parent | e979f8721731bc5f4cd0d65830548f9e70da2da5 (diff) |
QMimeDatabase: return a sorted list from d->mimeTypesForFileName()
All but one of the callers sorted the list in at least one
code path, with code paths that use the list unsorted looking
suspiciously non-deterministic. The one caller that doesn't
sort the list doesn't use it at all (but uses the out parameter,
which none of the other callers do, suggesting that the function
be split into two at some point).
Change-Id: I178c1476919e4877ef4f4a3cc8934dbd04bd7a58
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/mimetypes')
-rw-r--r-- | src/corelib/mimetypes/qmimedatabase.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index c1e17b9fc4..1df646a528 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -107,7 +107,8 @@ QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName, Q if (fileName.endsWith(QLatin1Char('/'))) return QStringList() << QLatin1String("inode/directory"); - const QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName(), foundSuffix); + QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName(), foundSuffix); + matchingMimeTypes.sort(); // make it deterministic return matchingMimeTypes; } @@ -200,7 +201,6 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa if (candidatesByName.count() > 1) { *accuracyPtr = 20; - candidatesByName.sort(); // to make it deterministic const QMimeType mime = mimeTypeForName(candidatesByName.at(0)); if (mime.isValid()) return mime; @@ -406,7 +406,6 @@ QMimeType QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode return d->mimeTypeForName(matches.first()); } else { // We have to pick one. - matches.sort(); // Make it deterministic return d->mimeTypeForName(matches.first()); } } else { @@ -434,7 +433,6 @@ QList<QMimeType> QMimeDatabase::mimeTypesForFileName(const QString &fileName) co QStringList matches = d->mimeTypeForFileName(fileName); QList<QMimeType> mimes; - matches.sort(); // Make it deterministic mimes.reserve(matches.count()); foreach (const QString &mime, matches) mimes.append(d->mimeTypeForName(mime)); |