From 63fcc294495e69d3c87b628ad7bc4e3d380e9578 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 20 Aug 2021 17:36:13 +0200 Subject: [PATCH] Fix CORBA::OBJECT_NOT_EXIST at the end of driver command --- src/SALOMEDS/SALOMEDS_Study_i.cxx | 38 +++++++++++++++++++------------ src/SALOMEDS/SALOMEDS_Study_i.hxx | 2 ++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 42da7d8c6..881bffb1f 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -416,14 +416,20 @@ void SALOMEDS_Study_i::Clear() //delete the builder servant PortableServer::POA_var poa=_default_POA(); - PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder); - poa->deactivate_object(anObjectId.in()); - _builder->_remove_ref(); - + try + { + PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder); + poa->deactivate_object(anObjectId.in()); + _builder->_remove_ref(); + } + catch(const CORBA::OBJECT_NOT_EXIST&) + { + delete _builder; + } RemovePostponed(-1); if (_impl->GetDocument()) { - SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator(); + std::unique_ptr itcomponent ( NewComponentIteratorImpl() ); for (; itcomponent->More(); itcomponent->Next()) { SALOMEDS::SComponent_var sco = itcomponent->Value(); CORBA::String_var compodatatype=sco->ComponentDataType(); @@ -450,9 +456,6 @@ void SALOMEDS_Study_i::Clear() } sco->UnRegister(); } - - //Does not need any more this iterator - itcomponent->UnRegister(); } // Notify GUI that study is cleared @@ -935,12 +938,7 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject } -//============================================================================ -/*! Function : NewComponentIterator - * Purpose : Create a SComponentIterator - */ -//============================================================================ -SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() +SALOMEDS_SComponentIterator_i *SALOMEDS_Study_i::NewComponentIteratorImpl() { SALOMEDS::Locker lock; @@ -949,8 +947,18 @@ SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_impl->NewComponentIterator(), _orb); it_servant->Init(); - SALOMEDS::SComponentIterator_var it = it_servant->_this(); + return it_servant; +} +//============================================================================ +/*! Function : NewComponentIterator + * Purpose : Create a SComponentIterator + */ +//============================================================================ +SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() +{ + SALOMEDS_SComponentIterator_i* it_servant = NewComponentIteratorImpl(); + SALOMEDS::SComponentIterator_var it = it_servant->_this(); return it._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 8de709f17..44731085c 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -216,6 +216,8 @@ public: */ virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator(); + SALOMEDS_SComponentIterator_i *NewComponentIteratorImpl(); + //! method to Create a StudyBuilder /*! \return StudyBuilder_ptr arguments, the created StudyBuilder -- 2.39.2