Avoid out of range exceptions.

This commit is contained in:
cc9cii 2014-10-09 07:01:18 +11:00
parent 70fd531722
commit 13f028e27b
2 changed files with 4 additions and 4 deletions

View file

@ -29,7 +29,7 @@ int CSMWorld::IdTable::columnCount (const QModelIndex & parent) const
QVariant CSMWorld::IdTable::data (const QModelIndex & index, int role) const QVariant CSMWorld::IdTable::data (const QModelIndex & index, int role) const
{ {
if (role!=Qt::DisplayRole && role!=Qt::EditRole) if ((role!=Qt::DisplayRole && role!=Qt::EditRole) || index.row() < 0 || index.column() < 0)
return QVariant(); return QVariant();
if (role==Qt::EditRole && !mIdCollection->getColumn (index.column()).isEditable()) if (role==Qt::EditRole && !mIdCollection->getColumn (index.column()).isEditable())
@ -229,4 +229,4 @@ bool CSMWorld::IdTable::isDeleted (const std::string& id) const
int CSMWorld::IdTable::getColumnId(int column) const int CSMWorld::IdTable::getColumnId(int column) const
{ {
return mIdCollection->getColumn(column).getId(); return mIdCollection->getColumn(column).getId();
} }

View file

@ -50,7 +50,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
{ {
int index = cells.searchId (iter->getId (mWorldspace)); int index = cells.searchId (iter->getId (mWorldspace));
if (index!=0 && cells.getRecord (index).mState!=CSMWorld::RecordBase::State_Deleted && if (index > 0 && cells.getRecord (index).mState!=CSMWorld::RecordBase::State_Deleted &&
mCells.find (*iter)==mCells.end()) mCells.find (*iter)==mCells.end())
{ {
if (setCamera) if (setCamera)
@ -315,4 +315,4 @@ void CSVRender::PagedWorldspaceWidget::cellAdded (const QModelIndex& index, int
/// \todo check if no selected cell is affected and do not update, if that is the case /// \todo check if no selected cell is affected and do not update, if that is the case
if (adjustCells()) if (adjustCells())
flagAsModified(); flagAsModified();
} }