Bug 377351

Summary: QFileDialog::getSaveFileName() checks for existing files before appending the file name extension
Product: [Plasma] plasma-integration Reporter: Frank Schaefer <fschaefer.oss>
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: ASSIGNED ---    
Severity: normal CC: kdelibs-bugs-null, nate
Priority: NOR    
Version First Reported In: 5.9.5   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Frank Schaefer 2017-03-07 19:15:24 UTC
When using a QFileDialog::getSaveFileName with automatic file name suffix appending enabled, the overwrite check is done before appending the file name extension, which is wrong.
I have verified that QFileDialog calls the native KDE dialog (Qts own dialog also doesn't provide automatic file name suffix appending).

Steps to reproduce:
1.) create a file called "aaa" (e.g. in the applications path)
2.) open save dialog, e.g. QString fileName = QFileDialog::getSaveFileName(this, "Save", QCoreApplication::applicationDirPath(), "test files(*.zzz)");
3.) enable automatic file name extension appending in the dialog
4.) enter file name "aaa"
5.) confirm saving

=> dialog should return file name "aaa.zzz" (file doesn't exist)
=> instead the user is asked to confirm overwrite of file "aaa" (which already exists)
=> if overwriting is confirmed, file name "aaa" is returned instead of "aaa.zzz"
(if "aaa" didn't exist and the overwrite check passes, "aaa.zzz" is returned as expected)

Used Qt version is 5.7.1.
Comment 1 Nate Graham 2020-09-08 14:59:20 UTC
Can you still reproduce this with Plasma 5.19?
Comment 2 Frank Schaefer 2020-09-12 12:37:07 UTC
Yes.
Comment 3 Bug Janitor Service 2025-08-05 21:58:44 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1967