KFileItemActions: fallback to default mimetype when selecting only files
ClosedPublic

Authored by elvisangelaccio on May 6 2018, 6:34 PM.

Details

Summary

KFileItemListProperties::mimeType() returns an empty string if the
selected files have different types, but KMimeTypeTrader does not
support empty mimetypes as query argument.

This causes the following warning

KMimeTypeTrader: mimeType "" not found

and breaks the bluedevil's 'Send via Bluetooth' plugin.

If we know the user selected only files, we can use the default mimetype
as fallback.

BUG: 393710
FIXED-IN: 5.47

Test Plan

Select two files with different extension and check 'Send via Bluetooth' is in the Dolphin context menu.

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
elvisangelaccio created this revision.May 6 2018, 6:34 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 6 2018, 6:34 PM
elvisangelaccio requested review of this revision.May 6 2018, 6:34 PM
dfaure added a comment.May 6 2018, 9:03 PM

Makes sense, but why not do this in KFileItemListProperties::mimeType()?

Makes sense, but why not do this in KFileItemListProperties::mimeType()?

That's what I wanted to do first, but then I realized it could be a change of behavior? The apidox says:

@return the mimetype of all items, if they all have the same, otherwise empty

and maybe someone could be relying on this.

Restricted Application added a subscriber: kde-frameworks-devel. · View Herald TranscriptMay 19 2018, 11:39 AM
dfaure accepted this revision.May 25 2018, 10:54 PM

It should be easy to use lxr to see which KDE applications uses KFileItemListProperties::mimeType(), but OK, your solution is safer in case of third-party applications.

This revision is now accepted and ready to land.May 25 2018, 10:54 PM
This revision was automatically updated to reflect the committed changes.