Skip to content
Snippets Groups Projects
Commit 34ef225b authored by Prince Gupta's avatar Prince Gupta :speech_balloon: Committed by Rémi Denis-Courmont
Browse files

qt: reset old contents while loading new in roundimage

fixes #26990
parent a11e147d
No related branches found
No related tags found
1 merge request!1953qt: reset old contents while loading new in roundimage
Pipeline #225523 passed with stage
in 14 minutes and 43 seconds
......@@ -131,6 +131,13 @@ QSGNode *RoundImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
auto node = static_cast<QSGImageNode *>(oldNode);
if (m_roundImage.isNull())
{
delete oldNode;
m_dirty = false;
return nullptr;
}
if (!node)
{
assert(window());
......@@ -141,28 +148,25 @@ QSGNode *RoundImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
if (m_dirty)
{
if (!m_roundImage.isNull())
{
assert(window());
m_dirty = false;
assert(window());
QSGTexture* texture = window()->createTextureFromImage(m_roundImage,
static_cast<QQuickWindow::CreateTextureOptions>((Q_LIKELY(m_roundImage.hasAlphaChannel()) ? QQuickWindow::TextureHasAlphaChannel
: 0) |
QQuickWindow::TextureCanUseAtlas));
QQuickWindow::CreateTextureOptions flags = QQuickWindow::TextureCanUseAtlas;
if (Q_LIKELY(m_roundImage.hasAlphaChannel()))
flags |= QQuickWindow::TextureHasAlphaChannel;
if (texture)
{
// No need to delete the old texture manually as it is owned by the node.
node->setTexture(texture);
node->markDirty(QSGNode::DirtyMaterial);
}
else
{
qmlWarning(this) << "Could not generate texture from " << m_roundImage;
}
}
QSGTexture* texture = window()->createTextureFromImage(m_roundImage, flags);
m_dirty = false;
if (texture)
{
// No need to delete the old texture manually as it is owned by the node.
node->setTexture(texture);
node->markDirty(QSGNode::DirtyMaterial);
}
else
{
qmlWarning(this) << "Could not generate texture from " << m_roundImage;
}
}
node->setRect(boundingRect());
......@@ -230,6 +234,12 @@ void RoundImage::regenerateRoundImage()
if (!isComponentComplete() || m_enqueuedGeneration)
return;
// remove old contents
m_dirty = true;
m_roundImage = {};
update();
setFlag(ItemHasContents, false); // update() is still required
m_roundImageGenerator.reset();
// use Qt::QueuedConnection to delay generation, so that dependent properties
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment