[kio] [Bug 220496] Preview of pictures when content type does not match extension

miklos bugzilla_noreply at kde.org
Sat Mar 31 14:30:45 BST 2018


https://bugs.kde.org/show_bug.cgi?id=220496

--- Comment #13 from miklos <mtmkls at gmail.com> ---
Now I found this again, and I had some time to debug it.

The file metadata is gathered by FileMetaDataWidget of baloo-widgets, which
launches an external program (baloo_filemetadata_temp_extractor) to parse the
file and return its properties, so the file description in the tooltip and the
information panel is always correct.

The preview is generated with KIO::PreviewJob(), which gets the mime type of
the file from its name: kio/src/widgets/previewjob.cpp:304 calls
kio/src/core/kfileitem.cpp:732, where QMimeDatabase is asked for the mime type
based on the file name. This is wrong when the file suffix is wrong, and
apparently there is a different preview generator for jpeg and png.

I see three possible solutions:
- QMimeDatabase supports parsing the file to find out its type
- do not filter for mime type in PreviewJob, try all preview generators and
accept the first success (the preview generators need to be ordered carefully
to minimize the chance of false positive)
- use the file properties gathered by baloo-widgets when requesting the preview
(this needs new API in KIO::PreviewJob, and I'm not sure if KIO is allowed to
depend on Baloo)

I'm leaning toward option 2. It works fine in Okular for example.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Unassigned-bugs mailing list