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 <oswald.buddenhagen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Tobias Hunger
2012-10-21 23:51:17 +02:00
parent 9884a76879
commit f50f1416a1

View File

@@ -1357,14 +1357,13 @@ bool MimeDatabasePrivate::addMimeType(MimeType mt)
} }
// insert the type. // insert the type.
m_typeMimeTypeMap.insert(type, MimeMapEntry(mt)); m_typeMimeTypeMap.insert(type, MimeMapEntry(mt));
// Register the children, resolved via alias map. Note that it is still // Register the children
// possible that aliases end up in the map if the parent classes are not inserted // Aliases will be resolved later once all mime types are known.
// at this point (thus their aliases not known).
const QStringList subClassesOf = mt.subClassesOf(); const QStringList subClassesOf = mt.subClassesOf();
if (!subClassesOf.empty()) { if (!subClassesOf.empty()) {
const QStringList::const_iterator socend = subClassesOf.constEnd(); const QStringList::const_iterator socend = subClassesOf.constEnd();
for (QStringList::const_iterator soit = subClassesOf.constBegin(); soit != socend; ++soit) for (QStringList::const_iterator soit = subClassesOf.constBegin(); soit != socend; ++soit)
m_parentChildrenMap.insert(resolveAlias(*soit), type); m_parentChildrenMap.insert(*soit, type);
} }
// register aliasses // register aliasses
const QStringList aliases = mt.aliases(); const QStringList aliases = mt.aliases();
@@ -1391,7 +1390,9 @@ void MimeDatabasePrivate::raiseLevelRecursion(MimeMapEntry &e, int level)
m_maxLevel = level; m_maxLevel = level;
// At all events recurse over children since nodes might have been // At all events recurse over children since nodes might have been
// added. // 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()) if (childTypes.empty())
return; return;
// look them up in the type->mime type map // look them up in the type->mime type map