Commit bfd41a95 authored by Alex Richardson's avatar Alex Richardson Committed by Alex Richardson
Browse files

KDEPlatformFileDialog: Fix initial directory selection for remote files

Summary:
Previously KDEPlatformFileDialogHelper::selectFile() would change
options()->initialDirectory() unconditionally even if it was already
set by the QFileDialog code. Since Qt 5.7.1 it is no longer necessary
to derive initialDirectory from the selectFile() call. In fact it is
actuall harmful since it will now override the correct initial directory
that was set by Qt. Without this patch I got the following debug output:

```
KDEPlatformFileDialogHelper::setDirectory QUrl("sftp://server/home/alr48/cheri/build_sdk.sh")
KDEPlatformFileDialogHelper::setDirectory QUrl("sftp://server/home/alr48/cheri/build_sdk.sh")
KDEPlatformFileDialogHelper::selectFile QUrl("file:///home/alex/build_sdk.sh")
KDEPlatformFileDialogHelper::setDirectory QUrl("file:///home/alex/)
```
The final setDirectory() call is actually a call to
`setDirectory(options->initialDirectory())` which was set in `selectFile()`.

We now depend on Qt 5.9 so we can remove this code without a check for
version >= 5.7.1.

BUG: 374913

Test Plan: Remote directory is now opened correctly (tested with Qt 5.10.0)

Reviewers: #plasma, elvisangelaccio

Reviewed By: elvisangelaccio

Subscribers: ngraham, krzyc, anthonyfieroni, elvisangelaccio, graesslin, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D4193
parent 47de67ea
......@@ -409,11 +409,6 @@ QUrl KDEPlatformFileDialogHelper::directory() const
void KDEPlatformFileDialogHelper::selectFile(const QUrl &filename)
{
m_dialog->selectFile(filename);
// Qt 5 at least <= 5.8.0 does not derive the directory from the passed url
// and set the initialDirectory option accordingly, also not for known schemes
// like file://, so we have to do it ourselves
options()->setInitialDirectory(m_dialog->directory());
}
void KDEPlatformFileDialogHelper::setDirectory(const QUrl &directory)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment