Bug 364086 - KFileDialog::setMimeFilter crashes when using native widgets
Summary: KFileDialog::setMimeFilter crashes when using native widgets
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kdelibs4support
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-08 07:38 UTC by Jonathan
Modified: 2017-02-26 23:53 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
This patch implements the tests required to avoid hitting the bug. (2.47 KB, patch)
2016-06-17 03:54 UTC, Jonathan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan 2016-06-08 07:38:25 UTC
Calling KFileDialog::setMimeFilter while using native widgets (for example on a Windows build) causes an immediate crash.

Reproducible: Always

Steps to Reproduce:
1.Start okular/kf5 for Windows
2.Select 'Open File'

Actual Results:  
Application crashes

Expected Results:  
The file chooser dialog appears

The coding error is obvious. Rather than calling d->w->setMimeFilter unconditionally, it should only do so if d->native is null. While some methods in KFileDialog test d->native correctly, a number of them do not:

KFileDialog::setMimeFilter
KFileDialog::sizeHint
KFileDialog::setConfirmOverwrite
KFileDialog::okButton
KFileDialog::cancelButton
KFileDialog::locationEdit
KFileDialog::filterWidget
KFileDialog::actionCollection
KFileDialog::toolBar
KFileDialog::fileWidget
Comment 1 Jonathan 2016-06-17 03:54:23 UTC
Created attachment 99542 [details]
This patch implements the tests required to avoid hitting the bug.

Some of the tests in the patch may be superfluous because the function can never be called when native widgets are used.
Comment 2 Kevin Funk 2016-06-29 06:37:37 UTC
Heya, Jonathan.

Could you upload that patch to Phabricator so it gets proper review? See https://community.kde.org/Get_Involved/development#Submitting_your_first_patch for more hints.
Comment 3 Jonathan 2016-06-29 12:00:51 UTC
No problems Kevin. I had a go but got a bit stumped when Phabricator asked me to nominate a repository. I had a look at the suggested ones but none seemed looked right, and the instructions weren't much help either. Could you point me in the right direction? Thanks!
Comment 4 Kevin Funk 2016-07-01 15:20:59 UTC
Unfortunately kdelibs4support.git has not been imported into Phab yet; this is all in the flux. You can leave the repository field empty afaik.
Comment 5 Jonathan 2016-07-04 02:05:25 UTC
OK I've done it here: https://phabricator.kde.org/D2075

The patch still needs reviewers.
Comment 6 Albert Astals Cid 2017-02-26 23:53:20 UTC
Git commit 1ba106517481213f116bfa5115dfe4d053176c17 by Albert Astals Cid, on behalf of Jonathan Schultz.
Committed on 26/02/2017 at 23:53.
Pushed by aacid into branch 'master'.

Fix bug in kfiledialog.cpp that causes crashing when native widgets are used.

This patch makes kfiledialog functions that did not already do so test the value of d->native before referencing d->w. This is important because if d->native is non-null then d->w will be null and referencing it cause an immediate crash. This was the case on Windows builds of okular when the file chooser was opened.
Differential Revision: https://phabricator.kde.org/D2075

M  +66   -56   src/kio/kfiledialog.cpp

https://commits.kde.org/kdelibs4support/1ba106517481213f116bfa5115dfe4d053176c17