summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2012-10-22 12:42:05 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-14 14:18:31 +0100
commit7721c3d27c6ad98f27de5ecd008d32b2efb25d59 (patch)
tree3abbc17a31c43bc7e0a789a1a285233accfb6bef /src
parent9346cb955230b3fbca8062a2fe8c912713011ce4 (diff)
QMimeDatabase: Fix handling of duplicate mimetype definitions.
When both freedesktop.org.xml and kde.xml define text/x-qml (*.qml), the XML provider would look up *.qml, see two mimetypes, and treat that as a glob conflict, and proceed with contents-based-determination, which for this sample file, would find "C source" due to the C comment. Fixed by ignoring duplicate pattern-mimetype associations. The binary-cache provider doesn't have this problem, update-mime-database already filters out duplicates when generating the on-disk extension tree. Change-Id: Ie335b0b419e7413fa0550779709513f68c2bfc68 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp
index 049a947939..b11add87e4 100644
--- a/src/corelib/mimetypes/qmimeglobpattern.cpp
+++ b/src/corelib/mimetypes/qmimeglobpattern.cpp
@@ -165,15 +165,15 @@ void QMimeAllGlobPatterns::addGlob(const QMimeGlobPattern &glob)
// The bulk of the patterns is *.foo with weight 50 --> those go into the fast patterns hash.
const QString extension = pattern.mid(2).toLower();
QStringList &patterns = m_fastPatterns[extension]; // find or create
- // This would just slow things down: if (!patterns.contains(glob.mimeType()))
- patterns.append(glob.mimeType());
+ if (!patterns.contains(glob.mimeType()))
+ patterns.append(glob.mimeType());
} else {
if (glob.weight() > 50) {
- // This would just slow things down: if (!m_highWeightGlobs.hasPattern(glob.mimeType(), glob.pattern()))
- m_highWeightGlobs.append(glob);
+ if (!m_highWeightGlobs.hasPattern(glob.mimeType(), glob.pattern()))
+ m_highWeightGlobs.append(glob);
} else {
- //This would just slow things down: if (!m_lowWeightGlobs.hasPattern(glob.mimeType(), glob.pattern()))
- m_lowWeightGlobs.append(glob);
+ if (!m_lowWeightGlobs.hasPattern(glob.mimeType(), glob.pattern()))
+ m_lowWeightGlobs.append(glob);
}
}
}