forked from qt-creator/qt-creator
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:
@@ -142,8 +142,9 @@ ProjectFileAdder::~ProjectFileAdder()
|
||||
|
||||
bool ProjectFileAdder::maybeAdd(const QString &path)
|
||||
{
|
||||
const Utils::MimeType mt = Utils::MimeDatabase::bestMatch(path, m_mimeTypes);
|
||||
if (mt.isValid()) {
|
||||
Utils::MimeDatabase mdb;
|
||||
const Utils::MimeType mt = mdb.mimeTypeForFile(path);
|
||||
if (m_mimeNameMapping.contains(mt.name())) {
|
||||
m_files << ProjectFile(path, m_mimeNameMapping.value(mt.name()));
|
||||
return true;
|
||||
}
|
||||
@@ -154,10 +155,8 @@ void ProjectFileAdder::addMapping(const char *mimeName, ProjectFile::Kind kind)
|
||||
{
|
||||
Utils::MimeDatabase mdb;
|
||||
Utils::MimeType mimeType = mdb.mimeTypeForName(QLatin1String(mimeName));
|
||||
if (mimeType.isValid()) {
|
||||
if (mimeType.isValid())
|
||||
m_mimeNameMapping.insert(mimeType.name(), kind);
|
||||
m_mimeTypes.append(mimeType);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user