summaryrefslogtreecommitdiffstats
path: root/examples/widgets/itemviews/fetchmore
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2017-12-31 12:38:33 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-01-03 07:53:33 +0000
commite95495142321fdf5c3a50a7ff6322a711be68555 (patch)
tree1db0357a70c43cfd93367c64e3693e2e959ff817 /examples/widgets/itemviews/fetchmore
parentfb58845d8f2aa0cffe031d3b16f041dcb61a51f8 (diff)
Fix QAbstractItemModel::beginRemoveRows in examples
QAbstractItemModel::beginRemoveRows() must not take a negative value for first or last. It will assert so we should make sure the examples are correct. The assertion was added in 00c09e752ff7e482e1308e0e34721dc979204595 Change-Id: I539175c0597ed6f0ae76b7493fd3dca40638714e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'examples/widgets/itemviews/fetchmore')
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
index cd21712e04..086d45eca3 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
@@ -103,6 +103,9 @@ void FileListModel::fetchMore(const QModelIndex & /* index */)
int remainder = fileList.size() - fileCount;
int itemsToFetch = qMin(100, remainder);
+ if (itemsToFetch <= 0)
+ return;
+
beginInsertRows(QModelIndex(), fileCount, fileCount+itemsToFetch-1);
fileCount += itemsToFetch;