Guard against Plasma::SVG giving us null pixmaps

On some themes Plasma::SVG gives empty pixmaps. Loading a null QImage to
an atlas texture causes a crash in old versions of Qt.

Guard against it.

BUG: 88039
Reviewed-by: Martin Klapetek
This commit is contained in:
David Edmundson 2014-08-13 15:07:42 +02:00
parent d4c9c20144
commit 1d83cc0baf

View File

@ -159,6 +159,14 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP
m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty());
const QImage image = m_svg.data()->image(QSize(width(), height()), m_elementID);
//despite having a valid size sometimes we still get a null QImage from Plasma::Svg
//loading a null texture to an atlas fatals
//Dave E fixed this in Qt in 5.3.something onwards but we need this for now
if (image.isNull()) {
delete textureNode;
return Q_NULLPTR;
}
QSharedPointer<QSGTexture> texture(window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas));
if (m_smooth) {
texture->setFiltering(QSGTexture::Linear);