[vlc-commits] [Git][videolan/vlc][master] qt: reset old contents while loading new in roundimage
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Sat May 28 12:58:01 UTC 2022
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
34ef225b by Prince Gupta at 2022-05-28T12:46:19+00:00
qt: reset old contents while loading new in roundimage
fixes #26990
- - - - -
1 changed file:
- modules/gui/qt/widgets/native/roundimage.cpp
Changes:
=====================================
modules/gui/qt/widgets/native/roundimage.cpp
=====================================
@@ -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
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/34ef225b1fbe9bc505309ac40f5886574f58399d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/34ef225b1fbe9bc505309ac40f5886574f58399d
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list