don't crash if the item list is empty
svn path=/trunk/KDE/kdebase/runtime/; revision=1190003
This commit is contained in:
parent
27bff00756
commit
7ec308a228
@ -102,13 +102,15 @@ void DataModel::setItems(const QVariantList &list)
|
|||||||
//convert to vector, so data() will be O(1)
|
//convert to vector, so data() will be O(1)
|
||||||
m_items = list.toVector();
|
m_items = list.toVector();
|
||||||
|
|
||||||
int role = Qt::UserRole;
|
if (!list.isEmpty()) {
|
||||||
m_roleNames.clear();
|
int role = Qt::UserRole;
|
||||||
foreach (QString roleName, list.first().value<QVariantMap>().keys()) {
|
m_roleNames.clear();
|
||||||
++role;
|
foreach (QString roleName, list.first().value<QVariantMap>().keys()) {
|
||||||
m_roleNames[role] = roleName.toLatin1();
|
++role;
|
||||||
|
m_roleNames[role] = roleName.toLatin1();
|
||||||
|
}
|
||||||
|
setRoleNames(m_roleNames);
|
||||||
}
|
}
|
||||||
setRoleNames(m_roleNames);
|
|
||||||
|
|
||||||
//make the declarative view reload everything,
|
//make the declarative view reload everything,
|
||||||
//would be nice an incremental update but is not possible
|
//would be nice an incremental update but is not possible
|
||||||
|
Loading…
x
Reference in New Issue
Block a user