summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qfileiconprovider.cpp
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2010-04-01 12:57:21 (GMT)
committerJens Bache-Wiig <jbache@trolltech.com>2010-04-01 13:03:17 (GMT)
commit3e287de62f677dd0a88d2fa9299059025f2db546 (patch)
tree27039d17ca558e5d0899d5376aaf01786dcbca32 /src/gui/itemviews/qfileiconprovider.cpp
parent9a2ad0cf5724e40f6e401f94904563d14a152f95 (diff)
downloadQt-3e287de62f677dd0a88d2fa9299059025f2db546.zip
Qt-3e287de62f677dd0a88d2fa9299059025f2db546.tar.gz
Qt-3e287de62f677dd0a88d2fa9299059025f2db546.tar.bz2
Fix crash in the fileiconprovider for Windows
In some cases the fileiconprovider has been reported to crash while accessing icons with overlays. This situation got worse with change b67bd25be08b54c3e6e49b2b9429e54ff58db268 since these cases were often hidden by broken caching. The workaround for now is to simply check that the hIcon structure is non empty before converting the icon. Task-number: QTBUG-8324 Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/itemviews/qfileiconprovider.cpp')
-rw-r--r--src/gui/itemviews/qfileiconprovider.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp
index fcc61e5..673065c 100644
--- a/src/gui/itemviews/qfileiconprovider.cpp
+++ b/src/gui/itemviews/qfileiconprovider.cpp
@@ -254,7 +254,9 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const
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 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const
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);