From 0c2e58d40c2946e0a3d81d033c2c8ce564fd44c1 Mon Sep 17 00:00:00 2001
From: Fatih Uzunoglu <fuzun54@outlook.com>
Date: Tue, 3 Dec 2024 02:32:24 +0200
Subject: [PATCH] qml: do not probe sibling visibility in `RoundImage.qml`

---
 modules/gui/qt/widgets/qml/RoundImage.qml | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/RoundImage.qml b/modules/gui/qt/widgets/qml/RoundImage.qml
index 431cdaca08c4..8cdd4caaee09 100644
--- a/modules/gui/qt/widgets/qml/RoundImage.qml
+++ b/modules/gui/qt/widgets/qml/RoundImage.qml
@@ -50,7 +50,9 @@ Item {
 
         anchors.fill: parent
 
-        visible: (root.radius > 0.0) && (GraphicsInfo.shaderType === GraphicsInfo.RhiShader)
+        visible: readyForVisibility
+
+        readonly property bool readyForVisibility: (root.radius > 0.0) && (GraphicsInfo.shaderType === GraphicsInfo.RhiShader)
 
         supportsAtlasTextures: true
 
@@ -84,7 +86,12 @@ Item {
 
         anchors.fill: parent
 
-        visible: !shaderEffect.visible
+        // Image should not be visible when there is rounding and RHI shader is supported.
+        // This is simply when the shader effect is invisible. However, Do not use `!shaderEffect.visible`,
+        // because the root item may be invisible (`grabToImage()` call on an invisible
+        // item case). In that case, shader effect would report invisible although it
+        // would appear in the grabbed image.
+        visible: !shaderEffect.readyForVisibility
 
         fillMode: Image.PreserveAspectCrop
     }
-- 
GitLab