MimeDatabase: Remove bestMatch, which was broken beyond repair

The problem is that, if you check e.g. a .pro file against all C/C++ mime
types, and these define magic matchers, it would find that .pro doesn't
match C/C++ mime types by extension, so it would open the file to find a
magic match. Even though the extension .pro would identify it already as
a qmake .pro file when checking for the mime type globally.

Change-Id: I3341187e88e2263bf38169c3c99e5d2161e2a9ee
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Eike Ziller
2015-02-27 16:02:25 +01:00
parent 6758b78ba6
commit 38b183fd90
7 changed files with 11 additions and 147 deletions

View File

@@ -81,14 +81,14 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
Target *activeTarget = 0;
if (project) {
MimeDatabase mdb;
QList<MimeType> qmlTypes;
foreach (const MimeType &mimeType, mdb.allMimeTypes()) {
if (mimeType.matchesName(QLatin1String(Constants::QML_MIMETYPE))
|| mimeType.allAncestors().contains(QLatin1String(Constants::QML_MIMETYPE)))
qmlTypes.append(mimeType);
}
QSet<QString> qmlTypeNames;
qmlTypeNames << QLatin1String(Constants::QML_MIMETYPE)
<< QLatin1String(Constants::QBS_MIMETYPE)
<< QLatin1String(Constants::QMLPROJECT_MIMETYPE)
<< QLatin1String(Constants::QMLTYPES_MIMETYPE)
<< QLatin1String(Constants::QMLUI_MIMETYPE);
foreach (const QString &filePath, project->files(Project::ExcludeGeneratedFiles)) {
if (mdb.bestMatch(filePath, qmlTypes).isValid())
if (qmlTypeNames.contains(mdb.mimeTypeForFile(filePath).name()))
projectInfo.sourceFiles << filePath;
}
activeTarget = project->activeTarget();