aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-07-05 16:57:12 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-06 08:37:55 +0000
commit11ac8a8b598fc79e38339519e52d4fe1a56ddaeb (patch)
tree2ce12192f7ca738f1f299d46997278de07d84c1c /src/quicktemplates2
parent2f5a6875c3b9a4ee5c647ebddd6defa6ca12d314 (diff)
Fix QQuickComboBox::textAt()
QQmlObjectModel::object() increases the reference count, and must be paired with QQmlObjectModel::release() to decrease the reference count when the object reference is no longer needed. When ComboBox model changed, previously created delegate instances weren't released as appropriate, because their reference counts were non-zero. Change-Id: I55d67b8baf3c00c1236155b1196a958b6db79e28 Task-number: QTBUG-54573 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 836d6806..cce61509 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -669,9 +669,16 @@ void QQuickComboBox::setPopup(QQuickPopup *popup)
QString QQuickComboBox::textAt(int index) const
{
Q_D(const QQuickComboBox);
- if (!d->delegateModel || index < 0 || index >= d->delegateModel->count() || !d->delegateModel->object(index))
+ if (!d->delegateModel || index < 0 || index >= d->delegateModel->count())
return QString();
- return d->delegateModel->stringValue(index, d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole);
+
+ QString text;
+ QObject *object = d->delegateModel->object(index);
+ if (object) {
+ text = d->delegateModel->stringValue(index, d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole);
+ d->delegateModel->release(object);
+ }
+ return text;
}
/*!