aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-07-28 11:17:21 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-28 04:34:31 +0200
commit0e008e9a8fc32d84c03e88a4a41ec8801b274979 (patch)
tree1ffe6e0cdba0f0061b3f13b026517c458999bf6d /src/declarative
parent44e201c04e699f3bee49f63894477f5105092cb0 (diff)
Fix crash when a model defines its own modelData role.
Don't create a duplicate modelData property if one has already been created from the model's roles. Task-number: QTBUG-18801 Change-Id: Ic46763a9dc067cfb53b0655d991c553b3b10f023 Reviewed-on: http://codereview.qt.nokia.com/2312 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/items/qsgvisualitemmodel.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/declarative/items/qsgvisualitemmodel.cpp b/src/declarative/items/qsgvisualitemmodel.cpp
index 66271e13d4..7e45aeb629 100644
--- a/src/declarative/items/qsgvisualitemmodel.cpp
+++ b/src/declarative/items/qsgvisualitemmodel.cpp
@@ -270,7 +270,7 @@ public:
++it;
}
// Add modelData property
- if (m_roles.count() == 1)
+ if (m_roles.count() == 1 && !m_roleNames.contains("modelData"))
m_modelDataPropId = m_delegateDataType->createProperty("modelData") - m_delegateDataType->propertyOffset();
m_metaDataCreated = true;
}
@@ -1061,16 +1061,15 @@ void QSGVisualDataModel::_q_itemsChanged(int index, int count,
qmlInfo(this) << "Changing role not present in item: " << roleName;
}
}
- if (d->m_roles.count() == 1) {
+ if (d->m_modelDataPropId != -1) {
// Handle the modelData role we add if there is just one role.
- int propId = data->modelDataPropertyId();
- if (data->hasValue(propId)) {
+ if (data->hasValue(d->m_modelDataPropId)) {
int role = d->m_roles.at(0);
if (d->m_listModelInterface) {
- data->setValue(propId, d->m_listModelInterface->data(idx, role));
+ data->setValue(d->m_modelDataPropId, d->m_listModelInterface->data(idx, role));
} else if (d->m_abstractItemModel) {
QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
- data->setValue(propId, d->m_abstractItemModel->data(index, role));
+ data->setValue(d->m_modelDataPropId, d->m_abstractItemModel->data(index, role));
}
}
}