src/gui/itemviews/qfileiconprovider.cpp
changeset 22 79de32ba3296
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
19:fcece45ef507 22:79de32ba3296
   252                         sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
   252                         sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
   253 #else
   253 #else
   254     val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
   254     val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
   255                         sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX);
   255                         sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX);
   256 #endif
   256 #endif
   257     if (val) {
   257 
       
   258     // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
       
   259     if (val && info.hIcon) {
   258         if (fileInfo.isDir() && !fileInfo.isRoot()) {
   260         if (fileInfo.isDir() && !fileInfo.isRoot()) {
   259             //using the unique icon index provided by windows save us from duplicate keys
   261             //using the unique icon index provided by windows save us from duplicate keys
   260             key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
   262             key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
   261             QPixmapCache::find(key, pixmap);
   263             QPixmapCache::find(key, pixmap);
   262             if (!pixmap.isNull()) {
   264             if (!pixmap.isNull()) {
   291                         sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
   293                         sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);
   292 #else
   294 #else
   293     val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
   295     val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
   294                         sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX);
   296                         sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX);
   295 #endif
   297 #endif
   296     if (val) {
   298     if (val && info.hIcon) {
   297         if (fileInfo.isDir() && !fileInfo.isRoot()) {
   299         if (fileInfo.isDir() && !fileInfo.isRoot()) {
   298             //using the unique icon index provided by windows save us from duplicate keys
   300             //using the unique icon index provided by windows save us from duplicate keys
   299             key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
   301             key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
   300         }
   302         }
   301 #ifndef Q_OS_WINCE
   303 #ifndef Q_OS_WINCE