Don't use QFileIconEngine if the platform theme won't support it

Change-Id: I6ccbfc5e8bc25018231a6924be12d74955e12337
Task-number: QTBUG-44981
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Gabriel de Dietrich 2015-03-13 11:34:48 +01:00
parent 6c372d46f8
commit d09f81864e

View File

@ -126,6 +126,9 @@ public:
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE
{
const QList<QSize> &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<int> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<int> >();
if (sizes.isEmpty())
return QIcon();
Q_Q(const QFileIconProvider);
return QIcon(new QFileIconEngine(q, fi));
}