From 6ab374f0fd530c841470f93c8befb92f1f646470 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 26 Nov 2013 14:59:10 +0100 Subject: ComboBox: Call resolveTextValue() after any model change Particularly if the nature of the model has changed (e.g., from null to array). Task-number: QTBUG-34936 Change-Id: If07690a8836dcd786ed7a32afda1e344d048d31f Reviewed-by: J-P Nurmi --- src/controls/ComboBox.qml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index db39f579..ad28efb5 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -432,7 +432,7 @@ Control { property ExclusiveGroup eg: ExclusiveGroup { id: eg } - property bool __modelIsArray: popupItems.model ? popupItems.model.constructor === Array : false + property bool modelIsArray: false Instantiator { id: popupItems @@ -440,6 +440,7 @@ Control { property bool updatingModel: false onModelChanged: { + popup.modelIsArray = !!model ? model.constructor === Array : false if (active) { if (updatingModel && popup.__selectedIndex === 0) { // We still want to update the currentText @@ -449,12 +450,13 @@ Control { popup.__selectedIndex = 0 } } + popup.resolveTextValue(comboBox.textRole) } MenuItem { text: popup.textRole === '' ? modelData : - ((popup.__modelIsArray ? modelData[popup.textRole] : model[popup.textRole]) || '') + ((popup.modelIsArray ? modelData[popup.textRole] : model[popup.textRole]) || '') onTriggered: { if (index !== currentIndex) activated(index) @@ -479,7 +481,7 @@ Control { } var get = model['get']; - if (!get && popup.__modelIsArray) { + if (!get && popup.modelIsArray && !!model[0]) { if (model[0].constructor !== String && model[0].constructor !== Number) get = function(i) { return model[i]; } } -- cgit v1.2.3