From f50f1416a1b036b0083d1558f5aaa8368efd439a Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Sun, 21 Oct 2012 23:51:17 +0200 Subject: [PATCH] MIME: Delay resolution of mime types aliases A MIME type can declare itself a sub-type of any other type. That may be an alias of some type not yet registered, so delay alias resolution till all MIME types are registered. Change-Id: Ie944771287f83e5439b120d12bed550266a6c954 Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint --- src/plugins/coreplugin/mimedatabase.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/coreplugin/mimedatabase.cpp b/src/plugins/coreplugin/mimedatabase.cpp index 05f5ab4fb84..800af0f6616 100644 --- a/src/plugins/coreplugin/mimedatabase.cpp +++ b/src/plugins/coreplugin/mimedatabase.cpp @@ -1357,14 +1357,13 @@ bool MimeDatabasePrivate::addMimeType(MimeType mt) } // insert the type. m_typeMimeTypeMap.insert(type, MimeMapEntry(mt)); - // Register the children, resolved via alias map. Note that it is still - // possible that aliases end up in the map if the parent classes are not inserted - // at this point (thus their aliases not known). + // Register the children + // Aliases will be resolved later once all mime types are known. const QStringList subClassesOf = mt.subClassesOf(); if (!subClassesOf.empty()) { const QStringList::const_iterator socend = subClassesOf.constEnd(); for (QStringList::const_iterator soit = subClassesOf.constBegin(); soit != socend; ++soit) - m_parentChildrenMap.insert(resolveAlias(*soit), type); + m_parentChildrenMap.insert(*soit, type); } // register aliasses const QStringList aliases = mt.aliases(); @@ -1391,7 +1390,9 @@ void MimeDatabasePrivate::raiseLevelRecursion(MimeMapEntry &e, int level) m_maxLevel = level; // At all events recurse over children since nodes might have been // added. - const QStringList childTypes = m_parentChildrenMap.values(e.type.type()); + QStringList childTypes = m_parentChildrenMap.values(e.type.type()); + foreach (const QString &alias, e.type.aliases()) + childTypes.append(m_parentChildrenMap.values(alias)); if (childTypes.empty()) return; // look them up in the type->mime type map