diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-02-18 15:16:57 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-02-18 15:27:02 +0000 |
commit | d877f0983db8b8f86167f626b1cf64cb4189c795 (patch) | |
tree | 795943bdfba3ccd0e395f795df5d08e3a0ec48b2 /src/libs/utils/mimetypes/mimeprovider.cpp | |
parent | 839d226d70b7bef5541917f18da101433c0ddd58 (diff) |
MimeDatabase: Prevent funny mixing of different mime type definitions
If multiple definitions for the same mime type are found, the mime XML
parser/provider would on the one hand replace the first MimeType instance
by the later one, but on the other hand keep all previously parsed glob
and magic matchers from the first definition.
The patch
- makes the XML parser ignore definitions of mime types that are already
defined
- parses custom types first, so custom types can override types from
freedesktop.org.xml
This fixes opening Cmake projects (CMakeLists.txt) in Qt Creator,
because freedesktop.org.xml defines these files to be x-cmake, but
we need them to be x-cmake-project.
Change-Id: Ia5598c2d0201f608aed6ae8c3268f0512d822f51
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
Diffstat (limited to 'src/libs/utils/mimetypes/mimeprovider.cpp')
-rw-r--r-- | src/libs/utils/mimetypes/mimeprovider.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libs/utils/mimetypes/mimeprovider.cpp b/src/libs/utils/mimetypes/mimeprovider.cpp index 79fc0c0748..8aad4fae07 100644 --- a/src/libs/utils/mimetypes/mimeprovider.cpp +++ b/src/libs/utils/mimetypes/mimeprovider.cpp @@ -833,7 +833,8 @@ void MimeXMLProvider::ensureLoaded() { if (!m_loaded /*|| shouldCheck()*/) { // bool fdoXmlFound = false; - QStringList allFiles; + // add custom mime types first, which overrides any default from freedesktop.org.xml + QStringList allFiles = m_additionalFiles; // const QStringList packageDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"), QStandardPaths::LocateDirectory); // //qDebug() << "packageDirs=" << packageDirs; @@ -851,11 +852,9 @@ void MimeXMLProvider::ensureLoaded() // if (!fdoXmlFound) { // // We could instead install the file as part of installing Qt? - allFiles.prepend(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml")); + allFiles.append(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml")); // } - allFiles.append(m_additionalFiles); - if (m_allFiles == allFiles) return; m_allFiles = allFiles; |