path: root/src
diff options
authorAlex Richardson <>2017-01-17 22:31:04 +0000
committerShawn Rutledge <>2018-02-01 04:57:11 +0000
commit4cd90a3579986ae7441c3e982a5f34cdfd92c152 (patch)
tree4fbd78ebc2b9ac80af31f9d32a175cc761231df6 /src
parent4a7771f206d4b29be549d3827c36a46679d90de6 (diff)
Fix native QFileDialog initial selection for remote URLs
When using QFileDialog::getOpenFileUrl() with dir set to e.g. "sftp://foo/bar.cpp" we call q->selectDirectoryUrl("sftp://foo") followed by q->selectFile("bar.cpp"). Inside QFileDialog::selectFile() we unconditionally convert "bar.cpp" to an absolute URL and then call d->selectFile_sys("$CWD/bar.cpp") This then calls platform integration that detects that an absolute URL is being passed to selectFile() and therefore overrides the initial directory. Initially reported as This is a regression that appeared some time between Qt 5.7.0 and 5.7.1. I have not had time to bisect this but the only commit that may have change behavior in that time range appears to be 007f92c6eef6191c48da0c44916591d48813ae62. Change-Id: I6968abe9ed5c5b9de067c453a7e9d2c5cdb3a190 Reviewed-by: Christoph Resch Reviewed-by: David Faure <>
Diffstat (limited to 'src')
1 files changed, 4 insertions, 1 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 8d37969be4..cb2c534b24 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -2830,7 +2830,10 @@ void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter,
if (!nameFilter.isEmpty())
- q->selectFile(initialSelection(directory));
+ if (directory.isLocalFile())
+ q->selectFile(initialSelection(directory));
+ else
+ q->selectUrl(directory);
// Try to restore from the FileDialog settings group; if it fails, fall back