From: Matthew Vogt Date: Wed, 18 Jan 2012 23:51:18 +0000 (+1000) Subject: Fix range checking in AbstractItemModel examples X-Git-Tag: upstream/5.2.1~2876 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a08d3e79fee46b33a75d17f76f0ff63687a648e;p=platform%2Fupstream%2Fqtdeclarative.git Fix range checking in AbstractItemModel examples Fix range checking in AbstractItemModel examples Task-number: QTBUG-23574 Change-Id: I6f2d4c18e1fb33ee369ebc75f501e524e8e63615 Reviewed-by: Martin Jones --- diff --git a/examples/declarative/modelviews/abstractitemmodel/model.cpp b/examples/declarative/modelviews/abstractitemmodel/model.cpp index f2397c3..2e4c7e2 100644 --- a/examples/declarative/modelviews/abstractitemmodel/model.cpp +++ b/examples/declarative/modelviews/abstractitemmodel/model.cpp @@ -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()]; diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp b/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp index f2397c3..2e4c7e2 100644 --- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp +++ b/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp @@ -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()];