Windows: Fix the last file dialog bottleneck.
Went from taking 30 seconds to 2 seconds, on a SDCard with 10k files. Windows file dialog does not resolve NTFS symlinks, it just shows an empty icon, and the link name, not the target. This allows for a big performance gain by reducing the number of calls to GetFileAttributesEx() by checking the extension directly. This also fixes the problems with the native file dialog, which for some reason, is creating a QFileSystemModel too. Task-number: QTBUG-13182 Change-Id: Ie2739765fd6c7daea64e3cf1d208ba9720bd39f2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
parent
5d12417c94
commit
9149f31aea
@ -238,7 +238,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if (fileInfo.isSymLink() && m_resolveSymlinks) {
|
||||
if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) {
|
||||
QFileInfo resolvedInfo(fileInfo.symLinkTarget());
|
||||
resolvedInfo = resolvedInfo.canonicalFilePath();
|
||||
if (resolvedInfo.exists()) {
|
||||
|
@ -108,7 +108,13 @@ public:
|
||||
return QExtendedInformation::System;
|
||||
}
|
||||
|
||||
bool isSymLink() const {
|
||||
bool isSymLink(bool ignoreNtfsSymLinks = false) const
|
||||
{
|
||||
if (ignoreNtfsSymLinks) {
|
||||
#ifdef Q_OS_WIN
|
||||
return !mFileInfo.suffix().compare(QLatin1String("lnk"), Qt::CaseInsensitive);
|
||||
#endif
|
||||
}
|
||||
return mFileInfo.isSymLink();
|
||||
}
|
||||
|
||||
|
@ -800,7 +800,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
|
||||
if (!index.isValid())
|
||||
return QString();
|
||||
QFileSystemNode *dirNode = node(index);
|
||||
if (dirNode->isSymLink() && fileInfoGatherer.resolveSymlinks()) {
|
||||
if (fileInfoGatherer.resolveSymlinks() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
|
||||
QString fullPath = QDir::fromNativeSeparators(filePath(index));
|
||||
if (resolvedSymLinks.contains(fullPath))
|
||||
return resolvedSymLinks[fullPath];
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
inline bool isFile() const { if (info) return info->isFile(); return true; }
|
||||
inline bool isSystem() const { if (info) return info->isSystem(); return true; }
|
||||
inline bool isHidden() const { if (info) return info->isHidden(); return false; }
|
||||
inline bool isSymLink() const { if (info) return info->isSymLink(); return false; }
|
||||
inline bool isSymLink(bool ignoreNtfsSymLinks = false) const { return info && info->isSymLink(ignoreNtfsSymLinks); }
|
||||
inline bool caseSensitive() const { if (info) return info->isCaseSensitive(); return false; }
|
||||
inline QIcon icon() const { if (info) return info->icon; return QIcon(); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user