Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...)
Operating System type and version
Fedora Linux 38
Description
Symptoms:
Without fixed path, with "jpg" chosen as preferred extension, when choosing to save a dialog shows up with a filter type that is not jpg, and the default filename has no suffix, so by default it is saved in another format (on my computer, "avif", lexically the first entry in the file filter type.)
The code assumes that the system's default mime type for a suffix that .mimeTypeForFile() returns must exist
in the master list returned by QImageWriter::supportedMimeTypes() - but this is not always true. And if the default
mime type is not present in the list, the file type filter selected is just the first one on the list, which does not accept
the suffix chosen with .setDefaultSuffix() and you get the behavior described above.
Additional Info/Workaround:
For me, the problem surfaced because I installed wine on my system, which shit-sprays the mime database with all kind of weird crap and breaks everything. As a result, the default mimetype for jpg is set to application/x-wine-extension-* for some reason.
Removing wine itself doesn't undo the damage. To clean up after wine, I followed this SO Answer which suggests:
#!/bin/bash
# Workaround for winemenubuilder bloating file associations by default
# Remove all existing associations
rm -f ~/.local/share/mime/packages/x-wine*
rm -f ~/.local/share/applications/wine-extension*
rm -f ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
rm -f ~/.local/share/mime/application/x-wine-extension*
# Disable winemenubuilder for all existing registries
# Replace ~/.bottles with your prefix/"bottle" directories
for sysreg in $(find ~/.wine ~/.bottles -name system.reg);
do
sed -i 's/winemenubuilder.exe -a/winemenubuilder.exe/' $sysreg
done
and I followed up with the shell command update-mime-database ~/.local/share/mime/ to regenerate the mime database which expunges the now-deleted crap from it. After that, the problem cleared.
However, as shitty as this behavior by wine is, I think it's still fair to say that it's a bug in flameshot that causes the failure in this situation.
Thank you for flameshot, it is an excellent thing. And also thanks for this bug, which helped me figure out a solution to the wine-induced mime weirdness that's been annoying me for literally a decade, and which I never bothered to investigate prior.
Flameshot Version
v12.1.0
Installation Type
Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...)
Operating System type and version
Fedora Linux 38
Description
Symptoms: Without fixed path, with "jpg" chosen as preferred extension, when choosing to save a dialog shows up with a filter type that is not jpg, and the default filename has no suffix, so by default it is saved in another format (on my computer, "avif", lexically the first entry in the file filter type.)
Analysis: Looking into the code, I think the issue is due to a logic error in
ShowSaveFileDialog()
. https://github.com/flameshot-org/flameshot/blob/fa29bcb4279b374ea7753fc4a514fd705499f7e7/src/utils/screenshotsaver.cpp#L77-L87https://github.com/flameshot-org/flameshot/blob/fa29bcb4279b374ea7753fc4a514fd705499f7e7/src/utils/screenshotsaver.cpp#L93-L95
The code assumes that the system's default mime type for a suffix that
.mimeTypeForFile()
returns must exist in the master list returned byQImageWriter::supportedMimeTypes()
- but this is not always true. And if the default mime type is not present in the list, the file type filter selected is just the first one on the list, which does not accept the suffix chosen with.setDefaultSuffix()
and you get the behavior described above.Additional Info/Workaround:
For me, the problem surfaced because I installed
wine
on my system, which shit-sprays the mime database with all kind of weird crap and breaks everything. As a result, the default mimetype for jpg is set toapplication/x-wine-extension-*
for some reason.Removing wine itself doesn't undo the damage. To clean up after wine, I followed this SO Answer which suggests:
and I followed up with the shell command
update-mime-database ~/.local/share/mime/
to regenerate the mime database which expunges the now-deleted crap from it. After that, the problem cleared.However, as shitty as this behavior by wine is, I think it's still fair to say that it's a bug in flameshot that causes the failure in this situation.
Thank you for flameshot, it is an excellent thing. And also thanks for this bug, which helped me figure out a solution to the wine-induced mime weirdness that's been annoying me for literally a decade, and which I never bothered to investigate prior.
Steps to reproduce
No response
Screenshots or screen recordings
No response
System Information
Wayland/Sway on Fedora 38