diff options
-rw-r--r-- | examples/widgets/itemviews/fetchmore/filelistmodel.cpp | 3 | ||||
-rw-r--r-- | examples/widgets/itemviews/puzzle/piecesmodel.cpp | 10 |
2 files changed, 9 insertions, 4 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; diff --git a/examples/widgets/itemviews/puzzle/piecesmodel.cpp b/examples/widgets/itemviews/puzzle/piecesmodel.cpp index f0649d3776..28b46836f4 100644 --- a/examples/widgets/itemviews/puzzle/piecesmodel.cpp +++ b/examples/widgets/itemviews/puzzle/piecesmodel.cpp @@ -203,10 +203,12 @@ Qt::DropActions PiecesModel::supportedDropActions() const void PiecesModel::addPieces(const QPixmap& pixmap) { - beginRemoveRows(QModelIndex(), 0, 24); - pixmaps.clear(); - locations.clear(); - endRemoveRows(); + if (!pixmaps.isEmpty()) { + beginRemoveRows(QModelIndex(), 0, pixmaps.size() - 1); + pixmaps.clear(); + locations.clear(); + endRemoveRows(); + } for (int y = 0; y < 5; ++y) { for (int x = 0; x < 5; ++x) { QPixmap pieceImage = pixmap.copy(x*m_PieceSize, y*m_PieceSize, m_PieceSize, m_PieceSize); |