Fix selectedNameFilter() multiple matches

Authored by hoffmannrobert on Jun 21 2019, 11:37 AM.



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

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.

BUG: 407819

Diff Detail

R135 Integration for Qt applications in Plasma
No Linters Available
No Unit Test Coverage
Build Status
Buildable 13115
Build 13133: arc lint + arc unit
Restricted Application added a project: Plasma. · View Herald TranscriptJun 21 2019, 11:37 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
hoffmannrobert requested review of this revision.Jun 21 2019, 11:37 AM
dfaure requested changes to this revision.Jun 22 2019, 8:05 AM

+1 for the included unittest.


(hehe I keep thinking this is about KDE-2 stuff... what a dinosaur I am)


the !filterText.isEmpty() && part is redundant.
In this part of the condition, we know it's not empty, otherwise shortcut evaluation happened after isEmpty returns true.

blue or (not blue and green)

is really the same as

blue or green
This revision now requires changes to proceed.Jun 22 2019, 8:05 AM
ngraham edited the test plan for this revision. (Show Details)Jun 22 2019, 8:34 AM
  • Remove redundant condition
hoffmannrobert marked an inline comment as done.Jun 22 2019, 8:48 AM
dfaure accepted this revision.Jun 22 2019, 10:26 PM
This revision is now accepted and ready to land.Jun 22 2019, 10:26 PM

Can you please push it for me, I don't have commit access. Thanks.

dfaure closed this revision.Jun 27 2019, 7:18 PM