From: akl Date: Thu, 1 Aug 2013 14:04:27 +0000 (+0000) Subject: Correction to avoid memory leaks (links to 0021708: [CEA 586]). X-Git-Tag: V7_3_0a1~233 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7a89c829749d2e60c4fbf3cef3b2354bd9d42d54;p=modules%2Fsmesh.git Correction to avoid memory leaks (links to 0021708: [CEA 586]). --- diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index 0dfa3da68..685bd953e 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -262,7 +262,7 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theStudy, theIOR ); SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder(); - SALOMEDS::SObject_var objAfter; + SALOMEDS::SObject_wrap objAfter; if ( SO->_is_nil() ) { if ( theTag == 0 ) { SO = aStudyBuilder->NewObject( theFatherObject ); @@ -273,15 +273,19 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy, std::string anEntry; int last2Pnt_pos = -1; int tagAfter = -1; + CORBA::String_var entry; + SALOMEDS::SObject_wrap curObj; SALOMEDS::UseCaseIterator_var anUseCaseIter = useCaseBuilder->GetUseCaseIterator(theFatherObject); for ( ; anUseCaseIter->More(); anUseCaseIter->Next() ) { - anEntry = anUseCaseIter->Value()->GetID(); - last2Pnt_pos = anEntry.rfind( ":" ); - tagAfter = atoi( anEntry.substr( last2Pnt_pos+1 ).c_str() ); - if ( tagAfter > theTag ) { - theFatherObject->FindSubObject( tagAfter, objAfter.inout() ); - break; - } + curObj = anUseCaseIter->Value(); + entry = curObj->GetID(); + anEntry = entry.in(); + last2Pnt_pos = anEntry.rfind( ":" ); + tagAfter = atoi( anEntry.substr( last2Pnt_pos+1 ).c_str() ); + if ( tagAfter > theTag ) { + objAfter = curObj; + break; + } } } } @@ -313,7 +317,7 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy, if ( !CORBA::is_nil( objAfter ) ) { useCaseBuilder->InsertBefore( SO, objAfter ); // insert at given tag } else if ( !useCaseBuilder->IsUseCaseNode( SO ) ) { - useCaseBuilder->AppendTo( SO->GetFather(), SO ); // append to the end of list + useCaseBuilder->AppendTo( theFatherObject, SO ); // append to the end of list } return SO._retn();