Bug 452566 - KDE offers to open mimetype with application twice when it inherits the association twice
Summary: KDE offers to open mimetype with application twice when it inherits the assoc...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kservice
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.93.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-13 05:01 UTC by Adam Fontenot
Modified: 2024-03-04 20:03 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Fontenot 2022-04-13 05:01:10 UTC
SUMMARY

This is related to, but not quite the same as, Bug 425154 (see last comment), which describes a corner case that still needs to be addressed...

Basically, if a mimetype inherits the same application twice (which can easily happen in multiple-inheritance cases), KDE will show the application twice in menus and the system settings module. 

STEPS TO REPRODUCE
1. Create a JSON file. 
2. Set okular to open the mimetypes "application/x-executable" and "text/plain". Apply changes.
3. Right click on the JSON file in dolphin, and see what programs are made available to open the file.

OBSERVED RESULT

Okular appears twice in the results.

EXPECTED RESULT

Okular appears once in the results, at the position it inherits *first* in a breadth-first search of the inherited mimetypes of application/json.

SOFTWARE/OS VERSIONS
Linux: Arch Linux (kernel 5.17.1)
KDE Plasma Version: 5.24.4 (X11)
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION

The positions Okular appears at in the results appear to suggest that kservice is searching the inherited mimetypes in depth-first order instead of breadth-first. This is incorrect and leads to the corner case issue described in the comments of Bug 425154.
Comment 1 Ahmad Samir 2022-04-15 20:03:58 UTC
First things first, could you verify you only have one okular .desktop file in /usr/share/applications/ and ~/.local/share/applications/ ?
Comment 2 Ahmad Samir 2022-04-15 20:05:04 UTC
To be more exact (because okular installs many .desktop files), org.kde.okular.desktop is the main one.
Comment 3 Adam Fontenot 2022-04-16 02:48:38 UTC
(In reply to Ahmad Samir from comment #1)
> First things first, could you verify you only have one okular .desktop file
> in /usr/share/applications/ and ~/.local/share/applications/ ?

Yes, I only have /usr/share/applications/org.kde.okular.desktop
Comment 4 Adam Fontenot 2024-03-04 20:03:16 UTC
I believe this has been fixed, probably as part of Bug 475200.

There is a related bug where certain applications that provide multiple .desktop files will be shown twice (or more). Okular is one of these: https://bugs.kde.org/show_bug.cgi?id=481473

There is a related bug describing user-confusing situations where an app unexpectedly inherits a file type due to a low level mimetype assignment like application/octet-stream: Bug 425154. Fortunately this situation is now much less painful thanks to two fixes to inheritance ordering. Okular should no longer take over all your files like it used to do.

I think I have managed to find and report all other issues with file associations, and they're now fixed as of Plasma 6!