diff options
-rw-r--r-- | src/plugins/platforms/windows/qwindowstheme.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 3e2cb5e9e9..7916211219 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -864,12 +864,18 @@ QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon } SHFILEINFO info; - const unsigned int flags = - SHGFI_ICON|iconSize|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX; - - const bool val = cacheableDirIcon && useDefaultFolderIcon - ? shGetFileInfoBackground(QString::fromWCharArray(L"dummy"), FILE_ATTRIBUTE_DIRECTORY, &info, flags | SHGFI_USEFILEATTRIBUTES) - : shGetFileInfoBackground(filePath, 0, &info, flags); + unsigned int flags = SHGFI_ICON | iconSize | SHGFI_SYSICONINDEX | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX; + DWORD attributes = 0; + QString path = filePath; + if (cacheableDirIcon && useDefaultFolderIcon) { + flags |= SHGFI_USEFILEATTRIBUTES; + attributes |= FILE_ATTRIBUTE_DIRECTORY; + path = QStringLiteral("dummy"); + } else if (!fileInfo().exists()) { + flags |= SHGFI_USEFILEATTRIBUTES; + attributes |= FILE_ATTRIBUTE_NORMAL; + } + const bool val = shGetFileInfoBackground(path, attributes, &info, flags); // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases if (val && info.hIcon) { |