If SvgItem size is 0, remove any nodes in the scenegraph

This commit is contained in:
David Edmundson 2014-07-14 16:26:16 +02:00
parent 96941f6c55
commit 9fc470089b

View File

@ -137,6 +137,12 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP
return Q_NULLPTR;
}
//this is more than just an optimisation, uploading a null image to QSGAtlasTexture causes a crash
if (width() == 0 || height() == 0) {
delete oldNode;
return Q_NULLPTR;
}
SVGTextureNode *textureNode = static_cast<SVGTextureNode *>(oldNode);
if (!textureNode) {
textureNode = new SVGTextureNode;
@ -152,6 +158,7 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP
//setContainsMultipleImages has to be done there since m_frameSvg can be shared with somebody else
m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty());
const QImage image = m_svg.data()->image(QSize(width(), height()), m_elementID);
QSGTexture *texture = window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
if (m_smooth) {
texture->setFiltering(QSGTexture::Linear);