diff options
author | Sukyoung Oh <sukyoung.oh@qt.io> | 2022-03-29 16:50:39 +0900 |
---|---|---|
committer | Sukyoung Oh <sukyoung.oh@qt.io> | 2022-03-29 17:04:20 +0900 |
commit | 684ed0323cd979c5ef472ef431ccbbb145c35e9f (patch) | |
tree | f3b1b81d258001eed4a7e08e1704098ba4e42854 /tests | |
parent | fb9d2be11ed53c106fbbb8eb73a3ae7902ecb4ab (diff) |
Reset provider's texture if QQuickNiniPatchImage's source is invalid
When QQuickNinePatchImage is used as a source of other shader related
object like ShaderEffect, OpacityMask or etc.,
there isn't a implementation to invalidate the provider's texture
when QQuickNinePatchImage is invalid.
It causes segmentation fault due to dangling pointer.
Fixes: QTBUG-100508
Change-Id: I9ea25fe68b41d3b15503e3dccea3a816ad485a20
(cherry picked from commit 81bbd0b45aeb1eb98efd9153c79ebf4f0e4be839)
Reviewed-by: <sukyoung.oh@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qquickimaginestyle/data/tst_imagine.qml | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/qquickimaginestyle/data/tst_imagine.qml b/tests/auto/qquickimaginestyle/data/tst_imagine.qml index b9078d78..f4ba1c71 100644 --- a/tests/auto/qquickimaginestyle/data/tst_imagine.qml +++ b/tests/auto/qquickimaginestyle/data/tst_imagine.qml @@ -153,4 +153,60 @@ TestCase { // Shouldn't result in a crash. afterRenderingSpy.wait(1000) } + + Component { + id: invalidNinePatchImageProvider + Item { + width: 200 + height: 200 + property alias ninePatchImage: np + + NinePatchImage { + id: np + source : "qrc:/test-assets/button-background-1.png" + cache: false + visible: false + } + ShaderEffect { + width: 300 + height: 300 + property variant src: np + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 coord; + void main() { + coord = qt_MultiTexCoord0; + gl_Position = qt_Matrix * qt_Vertex; + }" + fragmentShader: " + varying highp vec2 coord; + uniform sampler2D src; + uniform lowp float qt_Opacity; + void main() { + lowp vec4 tex = texture2D(src, coord); + gl_FragColor = vec4(vec3(dot(tex.rgb, + vec3(0.344, 0.5, 0.156))), + tex.a) * qt_Opacity; + }" + } + } + } + + function test_invalidNinePatchImageProvide() { + var container = createTemporaryObject(invalidNinePatchImageProvider, testCase) + verify(container); + + var afterRenderingSpy = signalSpyComponent.createObject(null, + { target: testCase.Window.window, signalName: "afterRendering" }) + verify(afterRenderingSpy.valid) + + afterRenderingSpy.wait(100) + container.ninePatchImage.source = "" + testCase.Window.window.update() + // Shouldn't result in a crash. + wait(10) + afterRenderingSpy.wait(100) + } } |