Fix range checking in AbstractItemModel examples
authorMatthew Vogt <matthew.vogt@nokia.com>
Wed, 18 Jan 2012 23:51:18 +0000 (09:51 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 19 Jan 2012 08:54:52 +0000 (09:54 +0100)
Fix range checking in AbstractItemModel examples

Task-number: QTBUG-23574
Change-Id: I6f2d4c18e1fb33ee369ebc75f501e524e8e63615
Reviewed-by: Martin Jones <martin.jones@nokia.com>
examples/declarative/modelviews/abstractitemmodel/model.cpp
examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp

index f2397c3..2e4c7e2 100644 (file)
@@ -77,7 +77,7 @@ int AnimalModel::rowCount(const QModelIndex & parent) const {
 }
 
 QVariant AnimalModel::data(const QModelIndex & index, int role) const {
-    if (index.row() < 0 || index.row() > m_animals.count())
+    if (index.row() < 0 || index.row() >= m_animals.count())
         return QVariant();
 
     const Animal &animal = m_animals[index.row()];
index f2397c3..2e4c7e2 100644 (file)
@@ -77,7 +77,7 @@ int AnimalModel::rowCount(const QModelIndex & parent) const {
 }
 
 QVariant AnimalModel::data(const QModelIndex & index, int role) const {
-    if (index.row() < 0 || index.row() > m_animals.count())
+    if (index.row() < 0 || index.row() >= m_animals.count())
         return QVariant();
 
     const Animal &animal = m_animals[index.row()];