VISU_Gen_i
::Close(SALOMEDS::SComponent_ptr theComponent)
{
- if ( !CORBA::is_nil( myStudyDocument ) && !CORBA::is_nil( theComponent ) &&
- myStudyDocument->StudyId() == theComponent->GetStudy()->StudyId())
- myStudyDocument = SALOMEDS::Study::_nil();
+ if ( !CORBA::is_nil( theComponent ) ) {
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ // 1. Decrement reference counter for published GenericObj-based servants
+ SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theComponent );
+ anIter->InitEx( true );
+ for ( ; anIter->More(); anIter->Next() ) {
+ SALOMEDS::SObject_var aSObject = anIter->Value();
+ if ( CORBA::is_nil( aSObject ) ) continue;
+ CORBA::Object_var anObject = aSObject->GetObject();
+ if ( CORBA::is_nil( anObject ) ) continue;
+ SALOME::GenericObj_var aGenericObj = SALOME::GenericObj::_narrow( anObject );
+ if ( !CORBA::is_nil( aGenericObj ) ) aGenericObj->UnRegister();
+ }
+
+ if ( !CORBA::is_nil( myStudyDocument ) && !CORBA::is_nil( aStudy ) &&
+ myStudyDocument->StudyId() == aStudy->StudyId() )
+ myStudyDocument = SALOMEDS::Study::_nil();
+ }
}