Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / Model / Model_Document.cxx
index 7c2077cb91c95d51c678da3e154a80f661ab96fb..b7f195242b01c28297f02a454a682fc245861acf 100644 (file)
@@ -226,8 +226,8 @@ shared_ptr<ModelAPI_Feature> Model_Document::feature(const string& theGroupID, c
 {
   // TODO: optimize this method
   shared_ptr<ModelAPI_Iterator>  anIter = featuresIterator(theGroupID);
-  for(int a = 0; a != theIndex; anIter->next()) a++;
-  return anIter->current();
+  for(int a = 0; a != theIndex && anIter->more(); anIter->next()) a++;
+  return anIter->more() ? anIter->current() : shared_ptr<ModelAPI_Feature>();
 }
 
 const vector<string>& Model_Document::getGroups() const