From 37590e2d2bd8965dea13876912afebc2fcf9f565 Mon Sep 17 00:00:00 2001 From: Martin Klapetek Date: Wed, 13 May 2015 19:05:01 +0200 Subject: [PATCH] Fix AssociatedApplicationManager lookup when a mimetype has no aliases QMimeType::aliases() does not return the main mimetype in the returned list and so when there are no aliases for a mimetype, there would be no associated application found as it would be querying for empty mimetype. This now always prepends the current mimetype to the list for which the apps are queried. REVIEW: 123779 BUG: 340326 FIXED-IN: 5.11 CHANGELOG: Fix AssociatedApplicationManager lookup when a mimetype has no aliases Change-Id: I322b03f2ac17fa4c0eb70fc3354c65a0f7a5e34c --- src/plasma/private/associatedapplicationmanager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plasma/private/associatedapplicationmanager.cpp b/src/plasma/private/associatedapplicationmanager.cpp index 01dd3193b..60ba596fd 100644 --- a/src/plasma/private/associatedapplicationmanager.cpp +++ b/src/plasma/private/associatedapplicationmanager.cpp @@ -72,7 +72,15 @@ public: for (i = urlLists.begin(); i != urlLists.end(); ++i) { QAction *a = i.key()->actions()->action("run associated application"); if (a) { - apps = KFileItemActions::associatedApplications(mimeDb.mimeTypeForUrl(i.value().first()).aliases(), QString()); + // This gets the current mimetype _and_ a list of its aliases, because aliases() + // do not return the current mimetype in it, so it needs to be prepended, + // especially for the cases where there are no aliases to be returned, + // this would then just return an empty list, returning the generic action even + // when there is a valid mimetype and an associated app + QStringList mimeTypes{mimeDb.mimeTypeForUrl(i.value().first()).name()}; + mimeTypes << mimeDb.mimeTypeForUrl(i.value().first()).aliases(); + + apps = KFileItemActions::associatedApplications(mimeTypes, QString()); if (!apps.isEmpty()) { a->setIcon(QIcon::fromTheme(apps.first()->icon())); a->setText(i18n("Open with %1", apps.first()->genericName().isEmpty() ? apps.first()->genericName() : apps.first()->name()));