summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-29 21:29:35 (GMT)
committerElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-29 21:29:35 (GMT)
commit1c86d08166ae8e9e937b9ea95e6ad7b5ee5fa511 (patch)
treee61c82dc560f22d9471c7554450487feac7cf51b
parentcb088d39fe2b9012e6f4b0f08c04b0212a77452d (diff)
pluginmanager: always return valid mimetypes
This fixes a small regression introduced by 1b817f61f1. Previously PluginManager would always return a list of *valid* mimetypes, because sortByComment() was filtering out invalid ones. After commit 1b817f61f1 sortByComment() is no longer unconditionally called, so the check for valid mimetypes needs to be moved. This was causing createdialogtest and adddialogtest to fail on the CI.
-rw-r--r--kerfuffle/pluginmanager.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/kerfuffle/pluginmanager.cpp b/kerfuffle/pluginmanager.cpp
index fd53f0c..13edf1a 100644
--- a/kerfuffle/pluginmanager.cpp
+++ b/kerfuffle/pluginmanager.cpp
@@ -117,8 +117,13 @@ Plugin *PluginManager::preferredWritePluginFor(const QMimeType &mimeType) const
QStringList PluginManager::supportedMimeTypes(MimeSortingMode mode) const
{
QSet<QString> supported;
+ QMimeDatabase db;
foreach (Plugin *plugin, availablePlugins()) {
- supported += plugin->metaData().mimeTypes().toSet();
+ foreach (const auto& mimeType, plugin->metaData().mimeTypes()) {
+ if (db.mimeTypeForName(mimeType).isValid()) {
+ supported.insert(mimeType);
+ }
+ }
}
// Remove entry for lrzipped tar if lrzip executable not found in path.
@@ -141,8 +146,13 @@ QStringList PluginManager::supportedMimeTypes(MimeSortingMode mode) const
QStringList PluginManager::supportedWriteMimeTypes(MimeSortingMode mode) const
{
QSet<QString> supported;
+ QMimeDatabase db;
foreach (Plugin *plugin, availableWritePlugins()) {
- supported += plugin->metaData().mimeTypes().toSet();
+ foreach (const auto& mimeType, plugin->metaData().mimeTypes()) {
+ if (db.mimeTypeForName(mimeType).isValid()) {
+ supported.insert(mimeType);
+ }
+ }
}
// Remove entry for lrzipped tar if lrzip executable not found in path.
@@ -224,9 +234,7 @@ QStringList PluginManager::sortByComment(const QSet<QString> &mimeTypes)
// Initialize the QMap to sort by comment.
foreach (const QString &mimeType, mimeTypes) {
QMimeType mime(QMimeDatabase().mimeTypeForName(mimeType));
- if (mime.isValid()) {
- map[mime.comment().toLower()] = mime.name();
- }
+ map[mime.comment().toLower()] = mime.name();
}
// Convert to sorted QStringList.