QMimeDatabase: adapt to changes in shared-mime-info 1.3

The generated xml file is now lowercase.
This was changed in shared-mime-info 3805d0bcf2.
It led to runtime warnings "No file found for ...", which helped notice the bug.

Change-Id: I31f0fc7f0fe8a098c3f79c0bcbeeb1909d2cc05a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2015-08-13 23:51:34 +02:00
parent 1ff66a7962
commit 4ccf5c6f4a
3 changed files with 10 additions and 6 deletions

View File

@ -560,10 +560,13 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
// load comment and globPatterns
const QString file = data.name + QLatin1String(".xml");
const QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file);
// shared-mime-info since 1.3 lowercases the xml files
QStringList mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file.toLower());
if (mimeFiles.isEmpty()) {
// TODO: ask Thiago about this
qWarning() << "No file found for" << file << ", even though the file appeared in a directory listing.";
mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file); // pre-1.3
}
if (mimeFiles.isEmpty()) {
qWarning() << "No file found for" << file << ", even though update-mime-info said it would exist.";
qWarning() << "Either it was just removed, or the directory doesn't have executable permission...";
qWarning() << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);
return;

View File

@ -897,7 +897,7 @@ void tst_QMimeDatabase::installNewGlobalMimeType()
QSKIP("shared-mime-info not found, skipping mime.cache test");
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
QString::fromLatin1("text/x-suse-ymu"));
QString::fromLatin1("text/x-SuSE-ymu"));
QVERIFY(db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
checkHasMimeType("text/x-suse-ymp");
@ -954,8 +954,9 @@ void tst_QMimeDatabase::installNewLocalMimeType()
}
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
QString::fromLatin1("text/x-suse-ymu"));
QString::fromLatin1("text/x-SuSE-ymu"));
QVERIFY(db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
QCOMPARE(db.mimeTypeForName(QLatin1String("text/x-SuSE-ymu")).comment(), QString("URL of a YaST Meta Package"));
checkHasMimeType("text/x-suse-ymp");
// Test that a double-definition of a mimetype doesn't lead to sniffing ("conflicting globs").

View File

@ -7,7 +7,7 @@
<glob pattern="*.ymp"/>
</mime-type>
<mime-type type="text/x-suse-ymu">
<mime-type type="text/x-SuSE-ymu">
<comment>URL of a YaST Meta Package</comment>
<glob pattern="*.ymu"/>
</mime-type>