Bug 407819 - KFileWidget returns wrong filter with enabled automatic extensions and extension used twice
Summary: KFileWidget returns wrong filter with enabled automatic extensions and extens...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (show other bugs)
Version: 5.54.0
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-22 08:06 UTC by Michael Weghorn
Modified: 2019-06-27 19:18 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Sample program to reproduce the issue (661 bytes, text/x-c++src)
2019-05-22 08:06 UTC, Michael Weghorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weghorn 2019-05-22 08:06:51 UTC
Created attachment 120238 [details]
Sample program to reproduce the issue

SUMMARY

(This is a follow-up for bug 407642.)
If your filter list has two matching filters for an extension, KFileWidget will return the name of the first filter when calling QFileDialog::selectedNameFilter(), even if the second filter was selected in the dialog.


STEPS TO REPRODUCE
1. Compile and run the attached program
2. Make sure that "auto extension" checkbox is enabled
3. Select the last file filter (DocBook (.xml)) via dropdown list
4. Click "Save"
5. Check program output

OBSERVED RESULT

The output is "Word 2003 XML (.xml) (*.xml)"


EXPECTED RESULT

The output should be "DocBook (.xml) (*.xml)", since this was selected in the file dialog.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
Operating System: Debian GNU/Linux 10
KDE Plasma Version: 5.14.5
Qt Version: 5.11.3
KDE Frameworks Version: 5.54.0 (+ backported fix for bug 407642 on top of kio package)
Kernel Version: 4.19.0-5-amd64
OS Type: 64-bit
Processors: 4 × Intel® Core™ i7-6500U CPU @ 2.50GHz
Memory: 31.3 GiB of RAM


ADDITIONAL INFORMATION

I used the "kio" version from Debian testing (version 5.54.1-1) and added the fix for bug 407642 on top for testing.
Comment 1 Michael Weghorn 2019-06-21 14:01:59 UTC
Pending chnage on Phabricator: https://phabricator.kde.org/D21959
Comment 2 David Faure 2019-06-27 19:18:21 UTC
Git commit 0f529bca29ba020820b0702ec5e28e9346d1e76d by David Faure, on behalf of Robert Hoffmann.
Committed on 27/06/2019 at 19:18.
Pushed by dfaure into branch 'Plasma/5.16'.

Fix selectedNameFilter() multiple matches

Summary:
If your filter list has two matching filters for an extension, KFileWidget
will return the name of the first filter when calling
QFileDialog::selectedNameFilter(), even if the second filter was selected
in the dialog.

This is a follow-up for https://phabricator.kde.org/D21249

Test Plan:
1. Compile and run the attached program to the bug report 407819
2. Make sure that "auto extension" checkbox is enabled
3. Select the last file filter (DocBook (.xml)) via dropdown list
4. Click "Save"
5. Check program output

Result without this patch:
The output is "Word 2003 XML (.xml) (*.xml)"

Result with this patch applied:
The output should be "DocBook (.xml) (*.xml)", since this was selected in the file dialog.

Reviewers: #frameworks, apol, dfaure

Reviewed By: dfaure

Subscribers: michaelweghorn, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21959

M  +17   -0    autotests/kfiledialog_unittest.cpp
M  +1    -0    src/platformtheme/kdeplatformfiledialogbase_p.h
M  +9    -3    src/platformtheme/kdeplatformfiledialoghelper.cpp
M  +1    -0    src/platformtheme/kdeplatformfiledialoghelper.h
M  +5    -0    src/platformtheme/kdirselectdialog.cpp
M  +1    -0    src/platformtheme/kdirselectdialog_p.h

https://commits.kde.org/plasma-integration/0f529bca29ba020820b0702ec5e28e9346d1e76d