widgets/cliprect: use layer.effect on content item over property
Some checks failed
Build / Nix (push) Has been cancelled
Build / Nix-1 (push) Has been cancelled
Build / Nix-2 (push) Has been cancelled
Build / Nix-3 (push) Has been cancelled
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled

ShaderEffectSource as a property not parented to an item does not
update its sourceItem's QQuickWindow when its own is changed. This
lead to use after frees and broken effects when using ClippingRectangle.
This commit is contained in:
outfoxxed 2026-01-28 00:23:38 -08:00
parent 191085a882
commit 1e4d804e7f
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
2 changed files with 11 additions and 13 deletions

View file

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import QtQuick
///! Rectangle capable of clipping content inside its border.
@ -24,7 +26,7 @@ Item {
/// Defaults to true if any corner has a non-zero radius, otherwise false.
property /*bool*/alias antialiasing: rectangle.antialiasing
/// The background color of the rectangle, which goes under its content.
property /*color*/alias color: shader.backgroundColor
property color color: "white"
/// See @@QtQuick.Rectangle.border.
property clippingRectangleBorder border
/// Radius of all corners. Defaults to 0.
@ -70,19 +72,14 @@ Item {
anchors.fill: parent
anchors.margins: root.contentInsideBorder ? root.border.width : 0
}
}
ShaderEffect {
id: shader
anchors.fill: root
fragmentShader: `qrc:/Quickshell/Widgets/shaders/cliprect${root.contentUnderBorder ? "-ub" : ""}.frag.qsb`
property Rectangle rect: rectangle
property color backgroundColor: "white"
property color borderColor: root.border.color
property ShaderEffectSource content: ShaderEffectSource {
hideSource: true
sourceItem: contentItemContainer
layer.enabled: true
layer.samplerName: "content"
layer.effect: ShaderEffect {
fragmentShader: `qrc:/Quickshell/Widgets/shaders/cliprect${root.contentUnderBorder ? "-ub" : ""}.frag.qsb`
property Rectangle rect: rectangle
property color backgroundColor: root.color
property color borderColor: root.border.color
}
}
}