diff --git a/src/desktopicon.cpp b/src/desktopicon.cpp --- a/src/desktopicon.cpp +++ b/src/desktopicon.cpp @@ -246,48 +246,51 @@ if (m_changed || node == 0) { QImage img; - const QSize size = QSize(width(), height()) * (window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()); - - switch(m_source.type()){ - case QVariant::Pixmap: - img = m_source.value().toImage(); - break; - case QVariant::Image: - img = m_source.value(); - break; - case QVariant::Bitmap: - img = m_source.value().toImage(); - break; - case QVariant::Icon: - img = m_source.value().pixmap(size, iconMode(), QIcon::On).toImage(); - break; - case QVariant::String: - img = findIcon(size); - break; - case QVariant::Brush: - case QVariant::Color: - //perhaps fill image instead? - default: - break; - } + const QSize itemSize(width(), height()); + + if (itemSize.width() != 0 && itemSize.height() != 0) { + const QSize size = itemSize * (window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()); + + switch(m_source.type()){ + case QVariant::Pixmap: + img = m_source.value().toImage(); + break; + case QVariant::Image: + img = m_source.value(); + break; + case QVariant::Bitmap: + img = m_source.value().toImage(); + break; + case QVariant::Icon: + img = m_source.value().pixmap(size, iconMode(), QIcon::On).toImage(); + break; + case QVariant::String: + img = findIcon(size); + break; + case QVariant::Brush: + case QVariant::Color: + //perhaps fill image instead? + default: + break; + } - if (img.isNull()){ - img = QImage(size, QImage::Format_Alpha8); - img.fill(Qt::transparent); - } - if (img.size() != size){ - img = img.scaled(size, Qt::KeepAspectRatioByExpanding, m_smooth ? Qt::SmoothTransformation : Qt::FastTransformation ); + if (img.isNull()){ + img = QImage(size, QImage::Format_Alpha8); + img.fill(Qt::transparent); + } + if (img.size() != size){ + img = img.scaled(size, Qt::KeepAspectRatioByExpanding, m_smooth ? Qt::SmoothTransformation : Qt::FastTransformation ); + } } m_changed = false; ManagedTextureNode* mNode = dynamic_cast(node); if (!mNode) { delete node; mNode = new ManagedTextureNode; } - mNode->setTexture(s_iconImageCache->loadTexture(window(), img)); - mNode->setRect(QRect(QPoint(0,0), QSize(width(), height()))); + mNode->setRect(QRect(QPoint(0,0), itemSize)); node = mNode; }