From bf9397c535971ec38668200ab465ebf20fa55ccf Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 11 May 2020 15:45:31 +0200 Subject: ComboBox: fix currentValue not being updated on model changes Make sure we call updateCurrentValue() where necessary. Fixes: QTBUG-83554 Change-Id: Iad593c2fc094a26429de1eda91bbdb152ffee2c2 Reviewed-by: Richard Moe Gustavsen (cherry picked from commit 3adeceaa1cfe5fae55ca6bd75226c52363a7e7d3) Reviewed-by: Qt Cherry-pick Bot --- src/quicktemplates2/qquickcombobox.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index d9bbd2bd..d7a67325 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -404,13 +404,13 @@ void QQuickComboBoxPrivate::createdItem(int index, QObject *object) } if (index == currentIndex && !q->isEditable()) - updateCurrentText(); + updateCurrentTextAndValue(); } void QQuickComboBoxPrivate::modelUpdated() { if (!extra.isAllocated() || !extra->accepting) - updateCurrentText(); + updateCurrentTextAndValue(); } void QQuickComboBoxPrivate::countChanged() @@ -866,11 +866,11 @@ void QQuickComboBox::setModel(const QVariant& m) if (QAbstractItemModel* aim = qvariant_cast(d->model)) { QObjectPrivate::disconnect(aim, &QAbstractItemModel::dataChanged, - d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentText)); + d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentTextAndValue)); } if (QAbstractItemModel* aim = qvariant_cast(model)) { QObjectPrivate::connect(aim, &QAbstractItemModel::dataChanged, - d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentText)); + d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentTextAndValue)); } d->model = model; @@ -878,7 +878,7 @@ void QQuickComboBox::setModel(const QVariant& m) emit countChanged(); if (isComponentComplete()) { setCurrentIndex(count() > 0 ? 0 : -1); - d->updateCurrentText(); + d->updateCurrentTextAndValue(); } emit modelChanged(); } @@ -1869,7 +1869,7 @@ bool QQuickComboBox::event(QEvent *e) { Q_D(QQuickComboBox); if (e->type() == QEvent::LanguageChange) - d->updateCurrentText(); + d->updateCurrentTextAndValue(); return QQuickControl::event(e); } -- cgit v1.2.3