Bug 440122 - Krita export overwrites files without asking
Summary: Krita export overwrites files without asking
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 4.4.5
Platform: Mint (Debian based) Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-21 18:40 UTC by Michal David
Modified: 2022-05-09 15:21 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot (75.15 KB, image/png)
2022-03-19 20:39 UTC, Bourumir Wyngs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal David 2021-07-21 18:40:45 UTC
SUMMARY
Krita doesn't ask to replace file while exporting some formats, unless the file extension is manually typed.

STEPS TO REPRODUCE
1. Export file "test.png"
2. Export file "test.png" in the same folder. Don't type out the ".png" extension, let Krita add it automatically

OBSERVED RESULT
When typing the file name, the existing file with the same name does not get highlighted in the file browser. The “test.png already exists. Do you want to replace it?” dialog doesn't show up, instead it skips to the export settings. With formats that don't have export settings (like .ppm), it replaces the file immediately after clicking export.

EXPECTED RESULT
Krita should always ask before replacing an existing file.

SOFTWARE/OS VERSIONS
Linux Mint 20.1 Cinnamon
tested in Krita 4.4.1, Krita 4.4.5

ADDITIONAL INFORMATION
Happens with: .png, .gif, .ppm, .tga
Does NOT happen with: .jpg, .exr - when exporting as .jpg or .exr, typing the name of an existing file will highlight it, and after clicking Export the dialog shows up.
It also does not happen if the full filename is written when exporting ("test.png" instead of just "test").
Comment 1 Ahab Greybeard 2021-07-22 10:09:03 UTC
I can replicate and confirm this for the July 21 5.0.0-prealpha (git 63be085) appimage on Debian 10.

I see the difference in highlighting in the file browser between .png and .jpg and lack of confirmation question for .png
Comment 2 Dmitry Kazakov 2021-07-30 06:24:22 UTC
That should be something linux-specific (or native dialogs specific). I cannot reproduce that on Windows.
Comment 3 Dmitry Kazakov 2021-07-30 06:50:43 UTC
The bug is reproducible on Linux with native dialogs disabled (I cannot enable native dialogs on Plasma)
Comment 4 Dmitry Kazakov 2021-07-30 06:58:48 UTC
Update: I can only reproduce this problem when running Krita from inside the docker environment. AppImage packages seem to work fine...
Comment 5 Michal David 2021-08-17 19:07:11 UTC
(In reply to Dmitry Kazakov from comment #4)
> Update: I can only reproduce this problem when running Krita from inside the
> docker environment. AppImage packages seem to work fine...

Hi, I forgot to mention it but this happened to me while using the AppImage version
Comment 6 Bourumir Wyngs 2022-03-19 20:39:50 UTC
Created attachment 147604 [details]
Screenshot

I am unable to reproduce this with Krita 4.2.9, see the screenshot. Could it be fixed?
Comment 7 Bourumir Wyngs 2022-03-19 20:43:29 UTC
(In reply to andviane from comment #6)
> Created attachment 147604 [details]
> Screenshot
> 
> I am unable to reproduce this with Krita 4.2.9, see the screenshot. Could it
> be fixed?

Sorry, understood. The fine name must be typed in by hand and with no extension. It works fine if the file name has been obtained by clicking on the exiting file if the file selection dialog.
Comment 8 Bourumir Wyngs 2022-03-20 12:10:54 UTC
This is because both Export and Save As dialogs rely on the native QFileDialog ability for checking and confirming the file overwrite. If we alter the file name later, as by adding the extension for the typed-in name without extension, this does not longer works as expected.
Comment 9 Bug Janitor Service 2022-03-20 12:53:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1379
Comment 10 Bug Janitor Service 2022-03-20 12:53:29 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1379
Comment 11 Alvin Wong 2022-05-09 15:21:27 UTC
Git commit 9d1dd6ed529d23c3ec4806ce3b0e4428155d7830 by Alvin Wong, on behalf of Bourumir Wyngs.
Committed on 09/05/2022 at 15:13.
Pushed by alvinwong into branch 'master'.

Set default file suffix in save dialog

When using Qt's non-native QFileDialog, this is needed for the save
dialog to correctly append the default file extension, so that the
dialog can correctly prompt the user before overwriting an existing
file.
Related: bug 412651

M  +46   -13   libs/widgetutils/KoFileDialog.cpp
M  +6    -3    libs/widgetutils/KoFileDialog.h

https://invent.kde.org/graphics/krita/commit/9d1dd6ed529d23c3ec4806ce3b0e4428155d7830
Comment 12 Alvin Wong 2022-05-09 15:21:43 UTC
Git commit 45b8fd5f867e7ea9fedc488cd2e034a616ea36fc by Alvin Wong.
Committed on 09/05/2022 at 15:13.
Pushed by alvinwong into branch 'master'.

ext_qt: Remove patches adding default file suffix

They didn't work quite well and relied on specific options being set in
caller code, so we are replacing it and handle the default file suffix
from Krita directly.
Related: bug 412651

D  +0    -156  3rdparty/ext_qt/0081-Fix-no-warning-for-overwriting-files-in-non-native-d.patch
D  +0    -186  3rdparty/ext_qt/0082-Make-jp-e-g-default-extensions-context-aware.patch
M  +0    -6    3rdparty/ext_qt/CMakeLists.txt

https://invent.kde.org/graphics/krita/commit/45b8fd5f867e7ea9fedc488cd2e034a616ea36fc
Comment 13 Alvin Wong 2022-05-09 15:21:59 UTC
Git commit 4a53db5eec2cba94af8824aa7c40709db38770bc by Alvin Wong.
Committed on 09/05/2022 at 15:13.
Pushed by alvinwong into branch 'master'.

Stop file dialog from silently appending file extension

If the file dialog does not return a file name with a valid file
extension, we ask the user to select a file name again. We must not just
append the file extension silently because:

* it bypasses the file overwrite prompt provided byu the file selector.
* doing so will break sandboxed macOS and Android because access to user
  files is restricted and must be done through the native file selector.

M  +55   -23   libs/widgetutils/KoFileDialog.cpp

https://invent.kde.org/graphics/krita/commit/4a53db5eec2cba94af8824aa7c40709db38770bc