From b493920c4bb1fc7fbaf93c2c96500c5278396ffa Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 5 Apr 2017 16:20:59 +0300 Subject: [PATCH] Issue #2102: Do not get object with Id of obsolete folder --- src/XGUI/XGUI_DataModel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 2eef35a76..88fb28eeb 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -644,7 +644,11 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & } else { // this is an object under sub document root std::string aType = myXMLReader->subType(); - ObjectPtr aObj = aSubDoc->object(aType, theRow - aNbSubFolders); + int aCount = theRow - aNbSubFolders; + // To check number of objects before using + if (aSubDoc->size(aType) <= aCount) + return QModelIndex(); + ObjectPtr aObj = aSubDoc->object(aType, aCount); aIndex = objectIndex(aObj); } } else { -- 2.39.2