diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-07-29 13:04:33 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-07-31 10:59:58 +0000 |
commit | 26c742c1e1c96740646bb1896df52bad2fbe105d (patch) | |
tree | 69802166c7d7c3a3ded202b00f27a0fae4952e42 /src/corelib/io/qfileinfo.h | |
parent | c5da2e6f063e262c8e9ea96793728be79fd09737 (diff) |
QFileSystemModel: make sure files are stat'ed in the worker thread
QFileInfoGatherer creates QFileInfo objects in the worker thread to
offload the work from the UI thread, but it never calls any methods on
the QFileInfo objects that would trigger a stat'ing of the files. For
large directories on remote file system, that easily results in the
UI thread being blocked for a very long time.
Add a private 'stat' method to QFileInfo which allows forcing it to
stat all attributes from the worker thread, and make
QFileInfoGatherer a friend so that it can call the function from the
worker thread. This way, QFileSystemModel can access the cached data
for each QFileInfo object, without having to touch the file system
from the UI thread.
Also reduce the amount of signal emissions for drive information,
batch all drives (which can safely be assumed to be at most a two
digit figure) into a single emission instead.
Change-Id: Ifdcae150406187db9984d0fec9add93597b5f85b
Fixes: QTBUG-41373
Pick-to: 5.15
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/io/qfileinfo.h')
-rw-r--r-- | src/corelib/io/qfileinfo.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index 2bed64eb1a..d7cc51c7df 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -189,6 +189,8 @@ protected: QSharedDataPointer<QFileInfoPrivate> d_ptr; private: + friend class QFileInfoGatherer; + void stat(); QFileInfoPrivate* d_func(); inline const QFileInfoPrivate* d_func() const { |