Summary: | KFileDialog No error when not enough permissions to enter folder | ||
---|---|---|---|
Product: | [Unmaintained] kdelibs | Reporter: | Ivo Anjo <ivo> |
Component: | general | Assignee: | kdelibs bugs <kdelibs-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | andresbajotierra, faure |
Priority: | NOR | Keywords: | investigated |
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Patch to preserve trailing slash when checking parent dir |
Description
Ivo Anjo
2009-04-29 11:39:01 UTC
Here using: Qt: 4.5.1 (qt-copy 958974) KDE: 4.2.71 (KDE 4.2.71 (KDE 4.3 >= 20090428)) kdelibs svn rev. 960693 / kdebase svn rev. 960693 on ArchLinux i686 - Kernel 2.6.29.1 I can confirm this behaviour I just checked the code. kdelibs/kfile/kdiroperator.cpp:1030~ ( "setUrl()" ) " if (!Private::isReadable(newurl)) { // maybe newurl is a file? check its parent directory newurl.setPath(newurl.directory()); if (newurl.equals(d->currUrl, KUrl::CompareWithoutTrailingSlash)) return; // parent is current dir, nothing to do (fixes #173454, too) KIO::UDSEntry entry; bool res = KIO::NetAccess::stat(newurl, entry, this); KFileItem i(entry, newurl); if ((!res || !Private::isReadable(newurl)) && i.isDir()) { resetCursor(); KMessageBox::error(d->itemView, i18n("The specified folder does not exist " "or was not readable.")); return; } else if (!i.isDir()) { return; } } " We are getting into " if (!Private::isReadable(newurl)) { // maybe newurl is a file? check its parent directory newurl.setPath(newurl.directory()); if (newurl.equals(d->currUrl, KUrl::CompareWithoutTrailingSlash)) return; // parent is current dir, nothing to do (fixes #173454, too) " So it returns before showing the error messagebox. @David: you introduced some of the code there (bug 173454) (even when the previous code should also fail I think). Should the messagebox code be moved up or will it affect the code. ? Regards (In reply to comment #2) > We are getting into > " > if (!Private::isReadable(newurl)) { > // maybe newurl is a file? check its parent directory > newurl.setPath(newurl.directory()); > if (newurl.equals(d->currUrl, KUrl::CompareWithoutTrailingSlash)) > return; // parent is current dir, nothing to do (fixes #173454, > too) > " > > So it returns before showing the error messagebox. I think Dario is right. The problem is that if current path is /x/ and we try to enter /x/y/ and hit this codepath, newurl.setPath(newurl.directory()) will set newurl as /x/ again, and so current path will equal newurl, and no error will be shown. This is because the default for KUrl::directory is KUrl::IgnoreTrailingSlash, so the last slash is "eaten". I think the correct thing to do is use the ObeyTrailingSlash, this way it works well for files (so bug 173454 is still fixed), and also fixes the problem for directories. Waiting for the OK to commit this to trunk and branch :) Index: kfile/kdiroperator.cpp =================================================================== --- kfile/kdiroperator.cpp (revision 996074) +++ kfile/kdiroperator.cpp (working copy) @@ -1056,7 +1056,7 @@ if (!Private::isReadable(newurl)) { // maybe newurl is a file? check its parent directory - newurl.setPath(newurl.directory()); + newurl.setPath(newurl.directory(KUrl::ObeyTrailingSlash)); if (newurl.equals(d->currUrl, KUrl::CompareWithoutTrailingSlash)) return; // parent is current dir, nothing to do (fixes #173454, too) KIO::UDSEntry entry; Created attachment 35542 [details]
Patch to preserve trailing slash when checking parent dir
I'm not confident to review this patch alone so I will wait a bit for David. You could also try to open a review request on reviewboard Submitted to reviewboard: http://reviewboard.kde.org/r/1230/ Looks good to me, please commit. SVN commit 1013462 by darioandres: - Show an error message when a folder can't be accesed in the filedialog BUG: 191016 M +1 -1 kdiroperator.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1013462 SVN commit 1013463 by darioandres: Backport to 4.3 of: SVN commit 1013462 by darioandres: - Show an error message when a folder can't be accesed in the filedialog CCBUG: 191016 M +1 -1 kdiroperator.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1013463 @Ivo Anjo: you can close the review request now :) |