From: eap Date: Wed, 24 Jul 2013 12:41:29 +0000 (+0000) Subject: 22261: EDF 2698 SMESH: Memory leak when displaying 2D quadratic elements as arcs X-Git-Tag: BR_hydro_v_0_3_1~152 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=84eccf2fcf025516ef1d5cc7606d71f9c119a58a;p=modules%2Fgeom.git 22261: EDF 2698 SMESH: Memory leak when displaying 2D quadratic elements as arcs Fix leaks of CORBA objects --- diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 7f6a12dd2..75e177984 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -62,6 +62,7 @@ #include #include +#include //============================================================================ // function : GEOM_Gen_i() @@ -574,25 +575,27 @@ CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, // Prepare a file name to open TCollection_AsciiString aNameWithExt(""); - if (isMultiFile) - aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath - (theComponent->GetStudy()->URL())).c_str()); - aNameWithExt += TCollection_AsciiString("_GEOM.sgd"); + SALOMEDS::Study_var study = theComponent->GetStudy(); + if (isMultiFile) { + CORBA::String_var url = study->URL(); + aNameWithExt = (char*)SALOMEDS_Tool::GetNameFromPath(url.in()).c_str(); + } + aNameWithExt += "_GEOM.sgd"; TCollection_AsciiString aFullName = (TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt); // Open document - if (!_impl->Load(theComponent->GetStudy()->StudyId(),(char*) aFullName.ToCString())) return false; + if (!_impl->Load(study->StudyId(),(char*) aFullName.ToCString())) return false; // Remove the created file and tmp directory if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); // creation of tree nodes for all data objects in the study // to support tree representation customization and drag-n-drop: - SALOMEDS::UseCaseBuilder_var useCaseBuilder = theComponent->GetStudy()->GetUseCaseBuilder(); + SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = study->GetUseCaseBuilder(); if ( !useCaseBuilder->IsUseCaseNode( theComponent ) ) { useCaseBuilder->SetRootCurrent(); useCaseBuilder->Append( theComponent ); // component object is added as the top level item - SALOMEDS::ChildIterator_var it = theComponent->GetStudy()->NewChildIterator( theComponent ); + SALOMEDS::ChildIterator_wrap it = study->NewChildIterator( theComponent ); for (it->InitEx(true); it->More(); it->Next()) { useCaseBuilder->AppendTo( it->Value()->GetFather(), it->Value() ); } @@ -756,10 +759,9 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, if(!theFather->_is_nil()) { IOR = _orb->object_to_string(theFather); - SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR.in()); + SALOMEDS::SObject_wrap aFatherSO = theStudy->FindObjectIOR(IOR.in()); if(aFatherSO->_is_nil()) return aResultSO._retn(); aResultSO = aStudyBuilder->NewObject(aFatherSO); - aFatherSO->UnRegister(); //aStudyBuilder->Addreference(aResultSO, aResultSO); } @@ -776,15 +778,13 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, GEOM::GEOM_Object_var anObject = aList[i]; if(anObject->_is_nil()) continue; IOR = _orb->object_to_string(anObject); - SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(IOR.in()); + SALOMEDS::SObject_wrap aSO = theStudy->FindObjectIOR(IOR.in()); if(aSO->_is_nil()) continue; CORBA::String_var anID = aSO->GetID(); if ( aPrevID == anID.in() ) continue; aPrevID = anID.in(); - SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO); + SALOMEDS::SObject_wrap aSubSO = aStudyBuilder->NewObject(aResultSO); aStudyBuilder->Addreference(aSubSO, aSO); - aSO->UnRegister(); - aSubSO->UnRegister(); } return aResultSO._retn();