From d09f81864e989b739d504e97bfc6b4a367bdfb22 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 13 Mar 2015 11:34:48 +0100 Subject: [PATCH] Don't use QFileIconEngine if the platform theme won't support it Change-Id: I6ccbfc5e8bc25018231a6924be12d74955e12337 Task-number: QTBUG-44981 Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge --- src/widgets/itemviews/qfileiconprovider.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index 740bd853b7..50ca733991 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -126,6 +126,9 @@ public: QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE { const QList &sizes = availableSizes(mode, state); + if (sizes.isEmpty()) + return QSize(); + foreach (const QSize &availableSize, sizes) { if (availableSize.width() >= size.width()) return availableSize; @@ -321,6 +324,14 @@ static bool isCacheable(const QFileInfo &fi) QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const { + const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); + if (!theme) + return QIcon(); + + QList sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value >(); + if (sizes.isEmpty()) + return QIcon(); + Q_Q(const QFileIconProvider); return QIcon(new QFileIconEngine(q, fi)); }