aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types/qqmllistmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/types/qqmllistmodel.cpp')
-rw-r--r--src/qml/types/qqmllistmodel.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index d4fc02cd3e..c4e33d572d 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -2351,21 +2351,22 @@ void QQmlListModel::append(QQmlV4Function *args)
QV4::ScopedObject argObject(scope);
int objectArrayLength = objectArray->getLength();
+ if (objectArrayLength > 0) {
+ int index = count();
+ emitItemsAboutToBeInserted(index, objectArrayLength);
- int index = count();
- emitItemsAboutToBeInserted(index, objectArrayLength);
+ for (int i=0 ; i < objectArrayLength ; ++i) {
+ argObject = objectArray->getIndexed(i);
- for (int i=0 ; i < objectArrayLength ; ++i) {
- argObject = objectArray->getIndexed(i);
-
- if (m_dynamicRoles) {
- m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));
- } else {
- m_listModel->append(argObject);
+ if (m_dynamicRoles) {
+ m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));
+ } else {
+ m_listModel->append(argObject);
+ }
}
- }
- emitItemsInserted();
+ emitItemsInserted();
+ }
} else if (argObject) {
int index;