mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-28 03:20:33 +05:00
IPAL8739. Fix ReleaseID() for the case ID == myMaxID && myPoolOfID.empty()
This commit is contained in:
parent
f5fcc431a4
commit
914e5a2f63
@ -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<int>::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<int>::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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user