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,6 +102,7 @@ void DataModel::setItems(const QVariantList &list)
|
|||
//convert to vector, so data() will be O(1)
|
||||
m_items = list.toVector();
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
int role = Qt::UserRole;
|
||||
m_roleNames.clear();
|
||||
foreach (QString roleName, list.first().value<QVariantMap>().keys()) {
|
||||
|
@ -109,6 +110,7 @@ void DataModel::setItems(const QVariantList &list)
|
|||
m_roleNames[role] = roleName.toLatin1();
|
||||
}
|
||||
setRoleNames(m_roleNames);
|
||||
}
|
||||
|
||||
//make the declarative view reload everything,
|
||||
//would be nice an incremental update but is not possible
|
||||
|
|
Loading…
Reference in New Issue
Block a user