summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-05-03 10:46:38 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-07-08 11:02:39 +0000
commit2300629df599938d67c13ed134e788db0fe8b21a (patch)
tree1fbfadda6dcab680f5ff7517fceaea7fb573ed0e /src/plugins/platforms/windows
parentfb78adf8df3cfb05e419ae248def1da6ad59c15a (diff)
QWindowsFileIconEngine::filePixmap(): Handle non-existent files
Pass SHGFI_USEFILEATTRIBUTES/FILE_ATTRIBUTE_NORMAL to ShGetFileInfo() in case a file does not exist to obtain an icon. SHGFI_USEFILEATTRIBUTES cannot be used unconditionally as it breaks custom directory icons. The functionality is then on par with XCB which obtains icons via QMimeDatabase look-up. Task-number: QTBUG-25319 Change-Id: Icd894d97fd8d1a2c4d5d39e86afe89843e6720c4 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp18
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) {