From 437da962c2b486b1a1722aac003bfa00b93ac204 Mon Sep 17 00:00:00 2001 From: Arnt Witteveen Date: Wed, 14 Mar 2012 14:53:32 +0100 Subject: Fix bug showing folder icons for files Fix an issue where the cache was updated with the folder icon, even though this is never used from the cache. This caused files to sometimes be shown with a folder icon: If a folder has an extension (e.g. a folder named 'folder.ext'), this means the folder icon will be written to the cache for the 'ext' extension, and from that point on all .ext files will be shown with the folder icon. The fix is to not save an icon in the cache for those cases where it will not be used from the cache anyway, by using the same condition for updating the cache as for reading it (which is in line 8 of the same function). Change-Id: I9ce8fca0718b2b62b9390fa64989acd54952a88e Reviewed-by: Girish Ramakrishnan Reviewed-by: Robin Burchell Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qfileiconprovider.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index b6669c0784..5356b67f99 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -376,15 +376,16 @@ QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const qt_mac_constructQIconFromIconRef(iconRef, 0, &retIcon); ReleaseIconRef(iconRef); - pixmap = retIcon.pixmap(16); - QPixmapCache::insert(keyBase + QLatin1String("16"), pixmap); - pixmap = retIcon.pixmap(32); - QPixmapCache::insert(keyBase + QLatin1String("32"), pixmap); - pixmap = retIcon.pixmap(64); - QPixmapCache::insert(keyBase + QLatin1String("64"), pixmap); - pixmap = retIcon.pixmap(128); - QPixmapCache::insert(keyBase + QLatin1String("128"), pixmap); - + if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) { + pixmap = retIcon.pixmap(16); + QPixmapCache::insert(keyBase + QLatin1String("16"), pixmap); + pixmap = retIcon.pixmap(32); + QPixmapCache::insert(keyBase + QLatin1String("32"), pixmap); + pixmap = retIcon.pixmap(64); + QPixmapCache::insert(keyBase + QLatin1String("64"), pixmap); + pixmap = retIcon.pixmap(128); + QPixmapCache::insert(keyBase + QLatin1String("128"), pixmap); + } return retIcon; } #endif -- cgit v1.2.3