Skip to content

Commit

Permalink
QFileDialog: Remember last visited directory correctly
Browse files Browse the repository at this point in the history
QFileDialogPrivate::init() sets the working directory derived
from the URL passed in, causing the lastVisitedDir to be set.
This in turn prevented the restoreState() logic from setting
the directory retrieved from the file. Clear lastVisitedDir
in init() in case the initial URL was invalid.

Fixes: QTBUG-70798
Change-Id: I19084e24eb6d469330c4dd8c50495b4996279189
Reviewed-by: Richard Moe Gustavsen <[email protected]>
  • Loading branch information
FriedemannKleint committed Dec 12, 2018
1 parent f10b980 commit 589f9f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/widgets/dialogs/qfiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2866,7 +2866,11 @@ void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter,
q->setFileMode(QFileDialog::AnyFile);
if (!nameFilter.isEmpty())
q->setNameFilter(nameFilter);
// QTBUG-70798, prevent the default blocking the restore logic.
const bool dontStoreDir = !directory.isValid() && !lastVisitedDir()->isValid();
q->setDirectoryUrl(workingDirectory(directory));
if (dontStoreDir)
lastVisitedDir()->clear();
if (directory.isLocalFile())
q->selectFile(initialSelection(directory));
else
Expand Down

0 comments on commit 589f9f1

Please sign in to comment.