Bug 173137 - KFileDialog returns erroneous selected files
Summary: KFileDialog returns erroneous selected files
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: general (show other bugs)
Version: 4.1
Platform: unspecified Unspecified
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-19 13:50 UTC by Seb Ruiz
Modified: 2010-10-29 00:51 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Seb Ruiz 2008-10-19 13:50:45 UTC
Version:            (using KDE 4.1.2)

Take the following code:

KFileDialog dlg( KUrl(QString()), QString("*.*|"), this );
dlg.setMode( KFile::Files );
dlg.exec();
KUrl::List files = dlg.selectedUrls();

This shows a file dialog which allows selecting of files. selectedUrls() returns the selected urls as expected.

However, when setting the mode to files or directories:

dlg.setMode( KFile::Files | KFile::Directories );

selectedUrls() returns the parent directory of the file which has been selected.

Reproducible in KDE 4.1.2 up to 4.2-SVN.
Comment 1 Rafael Fernández López 2008-10-19 15:58:37 UTC
SVN commit 873458 by ereslibre:

Test case for bug #173137. I cannot reproduce this issue... For testing the test case, execute kdelibs/kio/kfile/tests/kfiledialogtest and the first dialog is the test case. Select some files... the
result is the expected. Maybe the bug report is also very vague...

CCBUG: 173137


 M  +16 -0     kfiledialogtest.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=873458
Comment 2 Mark Kretschmann 2008-10-19 16:05:59 UTC
How is this report vague? I find it crystal clear. It's even got example code.
Comment 3 Rafael Fernández López 2008-10-19 16:21:20 UTC
It doesn't specify if with Files | Directory you get the parent folder url ONLY, the parent folder url AND the selected files...
Comment 4 Seb Ruiz 2008-10-19 23:20:35 UTC
Sorry, I should have been more specific - Files | Directory returns _only_ the parent directory of the selected files.
Comment 5 Rafael Fernández López 2008-10-19 23:34:59 UTC
Can you please the test case I wrote for this bug ? I cannot reproduce this problem with current trunk.
Comment 6 Seb Ruiz 2008-10-20 11:32:54 UTC
Okay, whilst running the unit test, I seem to have narrowed down the problem to be more specific!

Clicking on a single file in the dialog causes it to pretend to choose the selected file, however returns the parent directory.

Selecting a single file in the dialog so that it does not immediately return, and then clicking on the OK button, it seems to return the correct selected file.

Can you reproduce this?
Comment 7 Rafael Fernández López 2008-10-20 15:03:45 UTC
Yes, I could now reproduce... see Mark why I meant this report was a bit vague 
?

I will try to track it down (still fighting with other bug...).
Comment 8 Rafael Fernández López 2008-10-21 10:40:40 UTC
SVN commit 874314 by ereslibre:

No need to double connect things. activated() signal is enough. This was getting two times into the slotOK() method, which was returning more than the expected values.

BUG: 173137


 M  +0 -4      kdiroperator.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=874314
Comment 9 David Faure 2010-10-29 00:51:29 UTC
SVN commit 1190805 by dfaure:

Remove more code so that double-clicking on a file (in double-click mode) doesn't select the file + the dir + the dir again, in KFile::Files | KFile::Directory mode.
The activated() signal is indeed enough, no need to do anything about double-click explicitely anywhere.

Tested with the "bug 173137" testcase in kfiledialogtest, in single-click and double-click mode, and testing
 with click + Ok, Key_Enter, double-click. Hope I didn't miss anything.

The bug was already marked as fixed, but double-click global setting was probably not tested back then. Reported by xdarklight.
CCBUG: 173137


 M  +0 -39     kdiroperator.cpp  
 M  +2 -2      kdiroperator.h  
 M  +0 -11     kfilewidget.cpp  
 M  +0 -1      kfilewidget.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1190805