From: eap Date: Thu, 12 May 2005 05:22:18 +0000 (+0000) Subject: IPAL8739. Fix ReleaseID() for the case ID == myMaxID && myPoolOfID.empty() X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=914e5a2f6370a2d802d0977b2b89d248936b2adb;p=modules%2Fsmesh.git IPAL8739. Fix ReleaseID() for the case ID == myMaxID && myPoolOfID.empty() --- diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index 74ac917dd..536b2f783 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -57,16 +57,27 @@ int SMDS_MeshIDFactory::GetFreeID() //======================================================================= void SMDS_MeshIDFactory::ReleaseID(const int ID) { - if (ID > 0 && ID < myMaxID) myPoolOfID./*push*/insert(ID); - if (ID > 0 && ID == myMaxID ) { - set::iterator i = --myPoolOfID.end(); - while ( i != myPoolOfID.begin() ) - if ( --myMaxID != *(--i) ) - break; - if ( myMaxID == *i ) - --myMaxID; // begin of myPoolOfID reached - else - ++i; - myPoolOfID.erase( i, myPoolOfID.end() ); + if ( ID > 0 ) + { + if ( ID < myMaxID ) + { + myPoolOfID.insert(ID); + } + else if ( ID == myMaxID ) + { + --myMaxID; + if ( !myPoolOfID.empty() ) // assure that myMaxID is not in myPoolOfID + { + set::iterator i = --myPoolOfID.end(); + while ( i != myPoolOfID.begin() && myMaxID == *i ) { + --myMaxID; --i; + } + if ( myMaxID == *i ) + --myMaxID; // begin of myPoolOfID reached + else + ++i; + myPoolOfID.erase( i, myPoolOfID.end() ); + } + } } }