From d2796ee66b886a0d55faca933fba5c8301c8b303 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 29 Sep 2026 09:04:50 +0000 Subject: iOS: Refer to the delegate by id from its background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The backgrounds of the ComboBox and SearchField delegates read the delegate's properties unqualified, through the delegate's context. When the model is cleared, the delegate model releases the delegates and clears their context object first. The count change that follows still updates the delegates' own isSingleItem, isFirstItem and isLastItem properties, which in turn re-evaluates the backgrounds' bindings. Those can't find the names anymore then. Depending on whether the lookups were cached before, they either throw a ReferenceError or read undefined. Qualify the accesses with the delegate's id. The id stays valid until the delegate is actually deleted. Pick-to: 6.12 6.8 Change-Id: Id7e87d332f795135963e1c0465b3e43260d56479 Reviewed-by: Olivier De Cannière --- src/quickcontrols/ios/ComboBox.qml | 16 +++++++++------- src/quickcontrols/ios/SearchField.qml | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/quickcontrols/ios/ComboBox.qml b/src/quickcontrols/ios/ComboBox.qml index b7575160eb..935566dca3 100644 --- a/src/quickcontrols/ios/ComboBox.qml +++ b/src/quickcontrols/ios/ComboBox.qml @@ -28,6 +28,8 @@ T.ComboBox { rightPadding: padding + (control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing) delegate: MenuItem { + id: menuItem + width: ListView.view.width text: model[control.textRole] palette.text: control.palette.text @@ -45,19 +47,19 @@ T.ComboBox { background: Item { implicitHeight: 44 NinePatchImage { - y: isLastItem ? -1 : 0 + y: menuItem.isLastItem ? -1 : 0 width: parent.width - height: isLastItem ? parent.height + 1 : parent.height - rotation: isLastItem ? 180 : 0 - visible: !(isSingleItem && !control.delegate.pressed) + height: menuItem.isLastItem ? parent.height + 1 : parent.height + rotation: menuItem.isLastItem ? 180 : 0 + visible: !(menuItem.isSingleItem && !control.delegate.pressed) source: IOS.url + "menuitem-background" NinePatchImageSelector on source { states: [ - {"edge": isFirstItem || isLastItem }, - {"single": isSingleItem}, + {"edge": menuItem.isFirstItem || menuItem.isLastItem }, + {"single": menuItem.isSingleItem}, {"light": Application.styleHints.colorScheme === Qt.Light}, {"dark": Application.styleHints.colorScheme === Qt.Dark}, - {"pressed": down} + {"pressed": menuItem.down} ] } } diff --git a/src/quickcontrols/ios/SearchField.qml b/src/quickcontrols/ios/SearchField.qml index c332a5c5d6..5d683ff1cf 100644 --- a/src/quickcontrols/ios/SearchField.qml +++ b/src/quickcontrols/ios/SearchField.qml @@ -21,6 +21,8 @@ T.SearchField { rightPadding: padding + (control.mirrored || !clearIndicator.indicator || !clearIndicator.indicator.visible ? 0 : clearIndicator.indicator.width + spacing) delegate: MenuItem { + id: menuItem + width: ListView.view.width text: model[control.textRole] palette.text: control.palette.text @@ -40,19 +42,19 @@ T.SearchField { background: Item { implicitHeight: 44 NinePatchImage { - y: isLastItem ? -1 : 0 + y: menuItem.isLastItem ? -1 : 0 width: parent.width - height: isLastItem ? parent.height + 1 : parent.height - rotation: isLastItem ? 180 : 0 - visible: !(isSingleItem && !control.delegate.pressed) + height: menuItem.isLastItem ? parent.height + 1 : parent.height + rotation: menuItem.isLastItem ? 180 : 0 + visible: !(menuItem.isSingleItem && !control.delegate.pressed) source: IOS.url + "menuitem-background" NinePatchImageSelector on source { states: [ - {"edge": isFirstItem || isLastItem}, - {"single": isSingleItem}, + {"edge": menuItem.isFirstItem || menuItem.isLastItem}, + {"single": menuItem.isSingleItem}, {"light": Application.styleHints.colorScheme === Qt.Light}, {"dark": Application.styleHints.colorScheme === Qt.Dark}, - {"pressed": down} + {"pressed": menuItem.down} ] } } -- cgit v1.2.3