From e37616bbad5cadf07f6002f02da880c2630154cb Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 27 Dec 2013 16:58:31 +0100 Subject: [PATCH] QFileDialog::setDirectory() and directory() should be symmetric QFileDialog::setDirectory() calls options->setInitialDirectory(). Then QFileDialogPrivate::helperPrepareShow() calls it again with the result of QFileDialog::directory(). Assuming there are cases where that's actually necessary, we need QFileDialog::directory() to return the same one which was previously set in setDirectory(). Task-number: QTBUG-35779 Change-Id: Iac1f88c770ff1ef06a7f884f9a42d72674c967ba Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qfiledialog.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index da026d23a6..cd95b824a6 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1004,7 +1004,11 @@ void QFileDialog::setDirectory(const QString &directory) QDir QFileDialog::directory() const { Q_D(const QFileDialog); - return QDir(d->nativeDialogInUse ? d->directory_sys().toLocalFile() : d->rootPath()); + if (d->nativeDialogInUse) { + QString dir = d->directory_sys().toLocalFile(); + return QDir(dir.isEmpty() ? d->options->initialDirectory().toLocalFile() : dir); + } + return d->rootPath(); } /*!