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:
parent
1ff66a7962
commit
4ccf5c6f4a
@ -560,10 +560,13 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
|
|||||||
// load comment and globPatterns
|
// load comment and globPatterns
|
||||||
|
|
||||||
const QString file = data.name + QLatin1String(".xml");
|
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()) {
|
if (mimeFiles.isEmpty()) {
|
||||||
// TODO: ask Thiago about this
|
mimeFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1("mime/") + file); // pre-1.3
|
||||||
qWarning() << "No file found for" << file << ", even though the file appeared in a directory listing.";
|
}
|
||||||
|
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() << "Either it was just removed, or the directory doesn't have executable permission...";
|
||||||
qWarning() << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);
|
qWarning() << QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);
|
||||||
return;
|
return;
|
||||||
|
@ -897,7 +897,7 @@ void tst_QMimeDatabase::installNewGlobalMimeType()
|
|||||||
QSKIP("shared-mime-info not found, skipping mime.cache test");
|
QSKIP("shared-mime-info not found, skipping mime.cache test");
|
||||||
|
|
||||||
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
|
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());
|
QVERIFY(db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
|
||||||
checkHasMimeType("text/x-suse-ymp");
|
checkHasMimeType("text/x-suse-ymp");
|
||||||
|
|
||||||
@ -954,8 +954,9 @@ void tst_QMimeDatabase::installNewLocalMimeType()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
|
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());
|
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");
|
checkHasMimeType("text/x-suse-ymp");
|
||||||
|
|
||||||
// Test that a double-definition of a mimetype doesn't lead to sniffing ("conflicting globs").
|
// Test that a double-definition of a mimetype doesn't lead to sniffing ("conflicting globs").
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<glob pattern="*.ymp"/>
|
<glob pattern="*.ymp"/>
|
||||||
</mime-type>
|
</mime-type>
|
||||||
|
|
||||||
<mime-type type="text/x-suse-ymu">
|
<mime-type type="text/x-SuSE-ymu">
|
||||||
<comment>URL of a YaST Meta Package</comment>
|
<comment>URL of a YaST Meta Package</comment>
|
||||||
<glob pattern="*.ymu"/>
|
<glob pattern="*.ymu"/>
|
||||||
</mime-type>
|
</mime-type>
|
||||||
|
Loading…
Reference in New Issue
Block a user