From df4a8e919b90e7b451f8f49e7efb455733f80a2d Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Thu, 20 Feb 2025 14:03:11 +0100 Subject: [PATCH] FolderStatusModel: only create a single QFileIconProvider object otherwise the icons will end up being loaded from the system each time, which on Windows takes quite long (I saw many calls to `shell32.dll!SHDefExtractIcon` during profiling) Signed-off-by: Jyrki Gadinger --- src/gui/folderstatusmodel.cpp | 3 +-- src/gui/folderstatusmodel.h | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index d67e6e7475..d1211d7412 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -194,7 +193,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const } else if (subfolderInfo._size > 0 && isAnyAncestorEncrypted(index)) { return QIcon(QLatin1String(":/client/theme/lock-broken.svg")); } - return QFileIconProvider().icon(subfolderInfo._isExternal ? QFileIconProvider::Network : QFileIconProvider::Folder); + return _fileIconProvider.icon(subfolderInfo._isExternal ? QFileIconProvider::Network : QFileIconProvider::Folder); } case Qt::ForegroundRole: if (subfolderInfo._isUndecided || (subfolderInfo._isNonDecryptable && subfolderInfo._checked)) { diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h index 96b7467d14..7a776a64b8 100644 --- a/src/gui/folderstatusmodel.h +++ b/src/gui/folderstatusmodel.h @@ -21,6 +21,7 @@ #include #include #include +#include class QNetworkReply; namespace OCC { @@ -161,6 +162,8 @@ private: */ QMap _fetchingItems; + QFileIconProvider _fileIconProvider; + signals: void dirtyChanged();