forked from qt-creator/qt-creator
Fix opening of xml files.
They were either opened as text/plain, or, if they were empty, as application/vnd.rim.qnx.bar_descriptor types. This hotfix makes the mime database consider lower levels for matching by extension, if no match with maxweight was found, and reduces the weight of the application/xml type's ".xml" extension, so the bar_descriptor type can override this based on its content matcher. We should do a real fix in post-2.7. Task-number: QTCREATORBUG-8920 Change-Id: I3d6f4455ba23485d0229967eaa3eea6abe19746f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com>
This commit is contained in:
@@ -1493,7 +1493,7 @@ MimeType MimeDatabasePrivate::findByFile(const QFileInfo &f, unsigned *priorityP
|
|||||||
|
|
||||||
// Pass 1) Try to match on suffix
|
// Pass 1) Try to match on suffix
|
||||||
const TypeMimeTypeMap::const_iterator cend = m_typeMimeTypeMap.constEnd();
|
const TypeMimeTypeMap::const_iterator cend = m_typeMimeTypeMap.constEnd();
|
||||||
for (int level = m_maxLevel; level >= 0 && candidate.isNull(); level--) {
|
for (int level = m_maxLevel; level >= 0; level--) {
|
||||||
for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it) {
|
for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it) {
|
||||||
if (it.value().level == level) {
|
if (it.value().level == level) {
|
||||||
const unsigned suffixPriority = it.value().type.matchesFileBySuffix(context);
|
const unsigned suffixPriority = it.value().type.matchesFileBySuffix(context);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<alias type="text/xml"/>
|
<alias type="text/xml"/>
|
||||||
<sub-class-of type="text/plain"/>
|
<sub-class-of type="text/plain"/>
|
||||||
<comment>XML document</comment>
|
<comment>XML document</comment>
|
||||||
<glob pattern="*.xml"/>
|
<glob pattern="*.xml" weight="50"/><!-- reduce weight to allow application/vnd.rim.qnx.bar_descriptor to override by content -->
|
||||||
<glob pattern="*.xsl"/>
|
<glob pattern="*.xsl"/>
|
||||||
<glob pattern="*.xslt"/>
|
<glob pattern="*.xslt"/>
|
||||||
<glob pattern="*.xbl"/>
|
<glob pattern="*.xbl"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user