Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid row parameter check #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/seasidefilteredmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ void SeasideFilteredModel::populateIndex()

QVariantMap SeasideFilteredModel::get(int row) const
{
if(row < 0 || row >= m_contactIds->size()) {
return QVariantMap();
}

SeasideCache::CacheItem *cacheItem = existingItem(m_contactIds->at(row));
if (!cacheItem)
return QVariantMap();
Expand Down Expand Up @@ -675,6 +679,9 @@ QVariantMap SeasideFilteredModel::get(int row) const

QVariant SeasideFilteredModel::get(int row, int role) const
{
if(row < 0 || row >= m_contactIds->size()) {
return QVariant();
}
SeasideCache::CacheItem *cacheItem = existingItem(m_contactIds->at(row));
if (!cacheItem)
return QVariant();
Expand Down Expand Up @@ -703,7 +710,10 @@ SeasidePerson *SeasideFilteredModel::personByRow(int row) const
if(row < 0 || row >= m_contactIds->size()) {
return NULL;
}
return personFromItem(SeasideCache::itemById(m_contactIds->at(row)));
if(m_allContactIds->contains(row)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test for presence of the implicitly-converted value, not index validity. Also, should be m_contactIds, not m_allContactds (and index validity has already been tested...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @vranki

return personFromItem(m_allContactIds->at(row));
}
return NULL;
}

SeasidePerson *SeasideFilteredModel::personById(int id) const
Expand Down