diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index caaa12ed06a..339ee6dc8f9 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -394,9 +394,9 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa if (candidateByData.isValid() && magicAccuracy > 0) { const QString sniffedMime = candidateByData.name(); // If the sniffedMime matches a highest-weight glob match, use it - if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) { + if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) return candidateByData; - } + for (const QString &m : std::as_const(candidatesByName.m_allMatchingMimeTypes)) { if (inherits(m, sniffedMime)) { // We have magic + pattern pointing to this, so it's a pretty good match diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp index d50787a0be4..03ab04b5972 100644 --- a/src/corelib/mimetypes/qmimeglobpattern.cpp +++ b/src/corelib/mimetypes/qmimeglobpattern.cpp @@ -191,9 +191,9 @@ void QMimeAllGlobPatterns::addGlob(const QMimeGlobPattern &glob) const QString &pattern = glob.pattern(); Q_ASSERT(!pattern.isEmpty()); - // Store each patterns into either m_fastPatternDict (*.txt, *.html etc. with default weight 50) - // or for the rest, like core.*, *.tar.bz2, *~, into highWeightPatternOffset (>50) - // or lowWeightPatternOffset (<=50) + // Store each patterns into either m_fastPatternDict (*.txt, *.html + // etc. with default weight 50) or for the rest, like core.*, *.tar.bz2, *~, + // into highWeightPatternOffset (>50) or lowWeightPatternOffset (<=50). if (glob.weight() == 50 && isFastPattern(pattern) && !glob.isCaseSensitive()) { // The bulk of the patterns is *.foo with weight 50 --> those go into the fast patterns hash. @@ -249,12 +249,11 @@ void QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QMimeGlobMatch const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension); const QString simplePattern = "*."_L1 + simpleExtension; for (const QString &mime : matchingMimeTypes) { - if (filterFunc(mime)) { + if (filterFunc(mime)) result.addMatch(mime, 50, simplePattern, simpleExtension.size()); - } } - // Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway, - // at least those with weight 50. + // Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the + // low-weight mimetypes anyway, at least those with weight 50. } // Finally, try the low weight matches (<=50) diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index b4316355ba6..309e45bd5c3 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -45,7 +45,9 @@ public: static const unsigned DefaultWeight = 50; static const unsigned MinWeight = 1; - explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType, unsigned theWeight = DefaultWeight, Qt::CaseSensitivity s = Qt::CaseInsensitive) : + explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType, + unsigned theWeight = DefaultWeight, + Qt::CaseSensitivity s = Qt::CaseInsensitive) : m_pattern(s == Qt::CaseInsensitive ? thePattern.toLower() : thePattern), m_mimeType(theMimeType), m_weight(theWeight),