From 13f028e27ba8c993b96698792d3b2708d7822469 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 9 Oct 2014 07:01:18 +1100 Subject: [PATCH] Avoid out of range exceptions. --- apps/opencs/model/world/idtable.cpp | 4 ++-- apps/opencs/view/render/pagedworldspacewidget.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index 3a48317ef..c68b71789 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -29,7 +29,7 @@ int CSMWorld::IdTable::columnCount (const QModelIndex & parent) 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(); 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 { return mIdCollection->getColumn(column).getId(); -} \ No newline at end of file +} diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index ab594826d..a66a1bb7e 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -50,7 +50,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells() { 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()) { 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 if (adjustCells()) flagAsModified(); -} \ No newline at end of file +}