Be pedantic with Window's icon indexes.

Documentation for SHFILEINFO says iIcon is an index, so lets
initialize defaultFolderIIcon with -1 so it doesn't clash
with some icon that might exist at index 0.

Change-Id: Ic16538ee62e5433f3cdcceee19eb5d8d18d55c1e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Sérgio Martins 2013-09-06 15:23:05 +01:00 committed by The Qt Project
parent 4e6b696c08
commit 149f3efc39

View File

@ -671,7 +671,7 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
static QCache<QString, FakePointer<int> > dirIconEntryCache(1000);
static QMutex mx;
static int defaultFolderIIcon = 0;
static int defaultFolderIIcon = -1;
const bool useDefaultFolderIcon = iconOptions & QPlatformTheme::DontUseCustomDirectoryIcons;
QPixmap pixmap;
@ -687,8 +687,8 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
bool cacheableDirIcon = fileInfo.isDir() && !fileInfo.isRoot();
if (cacheableDirIcon) {
QMutexLocker locker(&mx);
int iIcon = (useDefaultFolderIcon && defaultFolderIIcon) ? defaultFolderIIcon
: **dirIconEntryCache.object(filePath);
int iIcon = (useDefaultFolderIcon && defaultFolderIIcon >= 0) ? defaultFolderIIcon
: **dirIconEntryCache.object(filePath);
if (iIcon) {
QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize, requestedImageListSize), pixmap);
if (pixmap.isNull()) // Let's keep both caches in sync
@ -720,7 +720,7 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
if (val && info.hIcon) {
QString key;
if (cacheableDirIcon) {
if (useDefaultFolderIcon && !defaultFolderIIcon)
if (useDefaultFolderIcon && defaultFolderIIcon < 0)
defaultFolderIIcon = info.iIcon;
//using the unique icon index provided by windows save us from duplicate keys