- if ( idx > 0 ) {
- SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
- if ( !aGeomGroup->_is_nil() ) {
- int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
- tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ),
- tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
- if ( res == 1 ) return;
- }
- aGroup = myGroups[idx-1];
+ if ( idx > 0 && idx <= myGroups.count() ) {
+ SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
+ if ( !aGeomGroup->_is_nil() ) {
+ int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
+ tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ),
+ tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
+ if ( res == 1 ) return;
+ }
+ aGroup = myGroups[idx-1];