src/gui/itemviews/qfileiconprovider.cpp
changeset 22 79de32ba3296
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/src/gui/itemviews/qfileiconprovider.cpp	Mon May 03 13:17:34 2010 +0300
+++ b/src/gui/itemviews/qfileiconprovider.cpp	Fri May 14 16:40:13 2010 +0300
@@ -254,7 +254,9 @@
     val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
                         sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX);
 #endif
-    if (val) {
+
+    // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
+    if (val && info.hIcon) {
         if (fileInfo.isDir() && !fileInfo.isRoot()) {
             //using the unique icon index provided by windows save us from duplicate keys
             key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
@@ -293,7 +295,7 @@
     val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
                         sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX);
 #endif
-    if (val) {
+    if (val && info.hIcon) {
         if (fileInfo.isDir() && !fileInfo.isRoot()) {
             //using the unique icon index provided by windows save us from duplicate keys
             key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);