summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfiledialog_p.h
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-08-10 16:03:17 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-08-12 23:06:36 +0200
commit5382bf4220bb76055943678196a84387510ee059 (patch)
treec1f065c290a64be8573cca3bb18fa228104574d1 /src/widgets/dialogs/qfiledialog_p.h
parent53da069b3294b45db05feca751a6d4569eb8c7ab (diff)
QFileDialog: reduce number of times a file is stat'ed
When opening a QFileDialog with an initial directory that lives on a disconnected network drive, repeatedly testing that directory consumes a significant amount of time during which the UI is blocked. To reduce the amount of file accesses, refactor the initialization code to allow sharing of a QFileInfo for the default case of operating on a local and absolute file system. This reduces the amount of stat calls significantly during startup time, and in case of a disconnected network shaves of 10-15 seconds of blocked UI, if Windows has already noticed that the file system is disconnected. Pick-to: 5.15 Fixes: QTBUG-6039 Change-Id: Ie082e447db214033291455bef2087cd05f366806 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/dialogs/qfiledialog_p.h')
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 42932bab5d..1d9929e36a 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -98,15 +98,15 @@ class QPlatformDialogHelper;
struct QFileDialogArgs
{
- QFileDialogArgs() : parent(nullptr), mode(QFileDialog::AnyFile) {}
+ QFileDialogArgs(const QUrl &url = {});
- QWidget *parent;
+ QWidget *parent = nullptr;
QString caption;
QUrl directory;
QString selection;
QString filter;
- QFileDialog::FileMode mode;
- QFileDialog::Options options;
+ QFileDialog::FileMode mode = QFileDialog::AnyFile;
+ QFileDialog::Options options = {};
};
#define UrlRole (Qt::UserRole + 1)
@@ -133,12 +133,9 @@ public:
void createMenuActions();
void createWidgets();
- void init(const QUrl &directory = QUrl(), const QString &nameFilter = QString(),
- const QString &caption = QString());
+ void init(const QFileDialogArgs &args);
bool itemViewKeyboardEvent(QKeyEvent *event);
QString getEnvironmentVariable(const QString &string);
- static QUrl workingDirectory(const QUrl &path);
- static QString initialSelection(const QUrl &path);
QStringList typedFiles() const;
QList<QUrl> userSelectedFiles() const;
QStringList addDefaultSuffixToFiles(const QStringList &filesToFix) const;