diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-05-11 10:24:18 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-05-11 11:13:04 +0200 |
commit | 809d305f938177cfb8488dc7fbfc28bc8eef9d20 (patch) | |
tree | d43688a9a3ef61af95c91bae3de8b00e6466c817 /src/qml/types/qqmllistmodel.cpp | |
parent | b742bf9415b42c6e34fab91d2f407eb23dc8e0da (diff) | |
parent | 1e82f11629e5572783e5bfc36f24ad10c235ca53 (diff) |
Merge remote-tracking branch 'origin/5.11.0' into wip/webassembly
Change-Id: Ice58db1687c0cfbd5a19e84ca9fa81b8d3fa7959
Diffstat (limited to 'src/qml/types/qqmllistmodel.cpp')
-rw-r--r-- | src/qml/types/qqmllistmodel.cpp | 23 |
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; |