From 7721c3d27c6ad98f27de5ecd008d32b2efb25d59 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 22 Oct 2012 12:42:05 +0200 Subject: 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 --- src/corelib/mimetypes/qmimeglobpattern.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib/mimetypes') 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); } } } -- cgit v1.2.3