aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2024-03-08 14:46:35 +0800
committerMitch Curtis <mitch.curtis@qt.io>2024-04-17 18:27:36 +0800
commitc7248004c942b7bcd9dad68148a7c3ab8c712c62 (patch)
treeb153c35d9859d9e49abcebb7a63b9bcec2c69656 /tests
parent967997d93390cbfb0365209e79fc97ee2afbb8c5 (diff)
Fix attached property propagation through ListView with Behavior
If the user had code like this: ApplicationWindow { // ... Material.theme: Material.Dark // ... ListView { // ... header: Text { Behavior on Material.elevation {} The meta type that QQuickAttachedPropertyPropagator saw when looking for the attached parent of the Text item was e.g. QQuickMaterialStyle_QML_125. However, QQmlMetaType::attachedPropertiesFunc only has attached property data for QQuickMaterialStyle (i.e. attached property types created from C++), and so it would never find the attached Material object on the parent window and would fall back to the engine's. Fix it by finding the first C++ meta object, which works even for attached types created in QML. Fixes: QTBUG-122783 Pick-to: 6.5 6.7 Change-Id: Ifd1b887b514ade4f320ace8a033d54cd16dbee1e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
index c824ede3c3..cdd8fb41e6 100644
--- a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
+++ b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml
@@ -1326,4 +1326,43 @@ TestCase {
let childWindow = parentWindow.childWindow
compare(childWindow.Material.theme, Material.Dark)
}
+
+ Component {
+ id: themePropagationWithBehaviorComponent
+
+ ApplicationWindow {
+ width: 200
+ height: 200
+ visible: true
+
+ Material.theme: Material.Dark
+
+ property alias listView: listView
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ header: Text {
+ text: `Material.theme for header is ${Material.theme} - should be 1`
+
+ Rectangle {
+ anchors.fill: parent
+ z: -1
+ }
+
+ Material.elevation: 6
+ // Having this would break the theme (QTBUG-122783)
+ Behavior on Material.elevation {}
+ }
+ }
+ }
+ }
+
+ function test_themePropagationWithBehavior() {
+ let window = createTemporaryObject(themePropagationWithBehaviorComponent, testCase)
+ verify(window)
+
+ let headerItem = window.listView.headerItem
+ compare(headerItem.Material.theme, Material.Dark)
+ }
}