Commit e5459fb9 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

QmlJS: Limit MIME type matching to extension

This improves performance of MIME type resolving on project loading.

When the MIME type cannot be resolved uniquely by extension to >50 weight,
the file preamble is read in order to match against magic values in the
MIME database.

In 3953e2b447862576902abef11ffb4efc56d7a625 the weight of the standard
file extensions was increased to 70, to at least avoid expensive matching
when the answer is obvious.

Qml types only have glob patterns anyway, so this shouldn't break

Change-Id: If3add50809a4361f877ea261fba6d6f333b2b740
Reviewed-by: default avatarNikolai Kosjar <>
Reviewed-by: default avatarEike Ziller <>
parent ba517fcf
......@@ -84,8 +84,10 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
<< QLatin1String(Constants::QMLTYPES_MIMETYPE)
<< QLatin1String(Constants::QMLUI_MIMETYPE);
foreach (const QString &filePath, project->files(Project::SourceFiles)) {
if (qmlTypeNames.contains(mdb.mimeTypeForFile(filePath).name()))
if (qmlTypeNames.contains(mdb.mimeTypeForFile(
filePath, MimeDatabase::MatchExtension).name())) {
projectInfo.sourceFiles << filePath;
activeTarget = project->activeTarget();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment