From b54de915866666710002c724589f2ef165fcf3a5 Mon Sep 17 00:00:00 2001 From: srn Date: Tue, 5 Apr 2005 12:20:50 +0000 Subject: [PATCH] Fixes of the return SObjects and SComponents that are NULL --- src/SALOMEDS/SALOMEDS_Study.cxx | 72 +++++++++++++++++++++----- src/SALOMEDS/SALOMEDS_StudyBuilder.cxx | 38 +++++++++++--- src/SALOMEDS/SALOMEDS_StudyManager.cxx | 52 +++++++++++++++---- 3 files changed, 133 insertions(+), 29 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 739e7d865..88d5ae603 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -100,8 +100,16 @@ SALOMEDSClient_SComponent* SALOMEDS_Study::FindComponent (const char* aComponent { SALOMEDS_SComponent* aSCO = NULL; TCollection_AsciiString aName((char*)aComponentName); - if(_isLocal) aSCO = new SALOMEDS_SComponent(_local_impl->FindComponent(aName)); - else aSCO = new SALOMEDS_SComponent(_corba_impl->FindComponent(aName.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponent(aName); + if(aSCO_impl.IsNull()) return NULL; + aSCO = new SALOMEDS_SComponent(aSCO_impl); + } + else { + SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent(aName.ToCString()); + if(CORBA::is_nil(aSCO_impl)) return NULL; + aSCO = new SALOMEDS_SComponent(aSCO_impl); + } return aSCO; } @@ -109,8 +117,16 @@ SALOMEDSClient_SComponent* SALOMEDS_Study::FindComponentID(const char* aComponen { SALOMEDS_SComponent* aSCO = NULL; TCollection_AsciiString anID((char*)aComponentID); - if(_isLocal) aSCO = new SALOMEDS_SComponent(_local_impl->FindComponentID(anID)); - else aSCO = new SALOMEDS_SComponent(_corba_impl->FindComponentID(anID.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponentID(anID); + if(aSCO_impl.IsNull()) return NULL; + aSCO = new SALOMEDS_SComponent(aSCO_impl); + } + else { + SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponentID(anID.ToCString()); + if(CORBA::is_nil(aSCO_impl)) return NULL; + aSCO = new SALOMEDS_SComponent(aSCO_impl); + } return aSCO; } @@ -119,8 +135,16 @@ SALOMEDSClient_SObject* SALOMEDS_Study::FindObject(const char* anObjectName) { SALOMEDS_SObject* aSO = NULL; TCollection_AsciiString aName((char*)anObjectName); - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->FindObject(aName)); - else aSO = new SALOMEDS_SObject(_corba_impl->FindObject(aName.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObject(aName); + if(aSO_impl.IsNull()) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } + else { + SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject(aName.ToCString()); + if(CORBA::is_nil(aSO_impl)) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } return aSO; } @@ -151,8 +175,16 @@ SALOMEDSClient_SObject* SALOMEDS_Study::FindObjectID(const char* anObjectID) { SALOMEDS_SObject* aSO = NULL; TCollection_AsciiString anID((char*)anObjectID); - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->FindObjectID(anID)); - else aSO = new SALOMEDS_SObject(_corba_impl->FindObjectID(anID.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectID(anID); + if(aSO_impl.IsNull()) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } + else { + SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectID(anID.ToCString()); + if(CORBA::is_nil(aSO_impl)) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } return aSO; } @@ -169,8 +201,16 @@ SALOMEDSClient_SObject* SALOMEDS_Study::FindObjectIOR(const char* anObjectIOR) { SALOMEDS_SObject* aSO = NULL; TCollection_AsciiString anIOR((char*)anObjectIOR); - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->FindObjectIOR(anIOR)); - else aSO = new SALOMEDS_SObject(_corba_impl->FindObjectIOR(anIOR.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectIOR(anIOR); + if(aSO_impl.IsNull()) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } + else { + SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR(anIOR.ToCString()); + if(CORBA::is_nil(aSO_impl)) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } return aSO; } @@ -178,8 +218,16 @@ SALOMEDSClient_SObject* SALOMEDS_Study::FindObjectByPath(const char* thePath) { SALOMEDS_SObject* aSO = NULL; TCollection_AsciiString aPath((char*)thePath); - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->FindObjectByPath(aPath)); - else aSO = new SALOMEDS_SObject(_corba_impl->FindObjectByPath(aPath.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectByPath(aPath); + if(aSO_impl.IsNull()) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } + else { + SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath(aPath.ToCString()); + if(CORBA::is_nil(aSO_impl)) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } return aSO; } diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index c552a2ce9..a952eecd6 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -49,10 +49,16 @@ SALOMEDSClient_SComponent* SALOMEDS_StudyBuilder::NewComponent(const char* Compo SALOMEDS_SComponent* aSCO = NULL; TCollection_AsciiString aType((char*)ComponentDataType); - if(_isLocal) - aSCO = new SALOMEDS_SComponent(_local_impl->NewComponent(aType)); - else - aSCO = new SALOMEDS_SComponent(_corba_impl->NewComponent(aType.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->NewComponent(aType); + if(aSCO_impl.IsNull()) return NULL; + aSCO = new SALOMEDS_SComponent(aSCO_impl); + } + else { + SALOMEDS::SComponent_var aSCO_impl = _corba_impl->NewComponent(aType.ToCString()); + if(CORBA::is_nil(aSCO_impl)) return NULL; + aSCO = new SALOMEDS_SComponent(aSCO_impl); + } return aSCO; } @@ -87,8 +93,16 @@ SALOMEDSClient_SObject* SALOMEDS_StudyBuilder::NewObject(SALOMEDSClient_SObject* SALOMEDS_SObject* aSO = NULL; SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject); if(father == NULL) return aSO; - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->NewObject(father->GetLocalImpl())); - else aSO = new SALOMEDS_SObject(_corba_impl->NewObject(father->GetCORBAImpl())); + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->NewObject(father->GetLocalImpl()); + if(aSO_impl.IsNull()) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } + else { + SALOMEDS::SObject_var aSO_impl = _corba_impl->NewObject(father->GetCORBAImpl()); + if(CORBA::is_nil(aSO_impl)) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } return aSO; } @@ -100,8 +114,16 @@ SALOMEDSClient_SObject* SALOMEDS_StudyBuilder::NewObjectToTag(SALOMEDSClient_SOb SALOMEDS_SObject* aSO = NULL; SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject); if(father == NULL) return aSO; - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->NewObjectToTag(father->GetLocalImpl(), theTag)); - else aSO = new SALOMEDS_SObject(_corba_impl->NewObjectToTag(father->GetCORBAImpl(), theTag)); + if(_isLocal) { + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->NewObjectToTag(father->GetLocalImpl(), theTag); + if(aSO_impl.IsNull()) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } + else { + SALOMEDS::SObject_var aSO_impl = _corba_impl->NewObjectToTag(father->GetCORBAImpl(), theTag); + if(CORBA::is_nil(aSO_impl)) return NULL; + aSO = new SALOMEDS_SObject(aSO_impl); + } return aSO; diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 55d3de1da..fc50e770a 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -50,8 +50,16 @@ SALOMEDSClient_Study* SALOMEDS_StudyManager::NewStudy(const char* study_name) SALOMEDS_Study* aStudy; TCollection_AsciiString aName((char*)study_name); - if(_isLocal) aStudy = new SALOMEDS_Study(_local_impl->NewStudy(aName)); - else aStudy = new SALOMEDS_Study(_corba_impl->NewStudy(aName.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->NewStudy(aName); + if(aStudy_impl.IsNull()) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } + else { + SALOMEDS::Study_var aStudy_impl = _corba_impl->NewStudy(aName.ToCString()); + if(CORBA::is_nil(aStudy_impl)) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } return aStudy; } @@ -61,8 +69,16 @@ SALOMEDSClient_Study* SALOMEDS_StudyManager::Open(const char* theStudyUrl) SALOMEDS_Study* aStudy; TCollection_AsciiString aName((char*)theStudyUrl); - if(_isLocal) aStudy = new SALOMEDS_Study(_local_impl->Open(aName)); - else aStudy = new SALOMEDS_Study(_corba_impl->Open(aName.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->Open(aName); + if(aStudy_impl.IsNull()) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } + else { + SALOMEDS::Study_var aStudy_impl = _corba_impl->Open(aName.ToCString()); + if(CORBA::is_nil(aStudy_impl)) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } return aStudy; } @@ -128,16 +144,32 @@ SALOMEDSClient_Study* SALOMEDS_StudyManager::GetStudyByName(const char* theStudy { SALOMEDS_Study* aStudy = NULL; TCollection_AsciiString aName((char*)theStudyName); - if(_isLocal) aStudy = new SALOMEDS_Study(_local_impl->GetStudyByName(aName)); - else aStudy = new SALOMEDS_Study(_corba_impl->GetStudyByName(aName.ToCString())); + if(_isLocal) { + Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->GetStudyByName(aName); + if(aStudy_impl.IsNull()) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } + else { + SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByName(aName.ToCString()); + if(CORBA::is_nil(aStudy_impl)) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } return aStudy; } SALOMEDSClient_Study* SALOMEDS_StudyManager::GetStudyByID(int theStudyID) { SALOMEDS_Study* aStudy = NULL; - if(_isLocal) aStudy = new SALOMEDS_Study(_local_impl->GetStudyByID(theStudyID)); - else aStudy = new SALOMEDS_Study(_corba_impl->GetStudyByID(theStudyID)); + if(_isLocal) { + Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->GetStudyByID(theStudyID); + if(aStudy_impl.IsNull()) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } + else { + SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByID(theStudyID); + if(CORBA::is_nil(aStudy_impl)) return NULL; + aStudy = new SALOMEDS_Study(aStudy_impl); + } return aStudy; } @@ -166,7 +198,9 @@ SALOMEDSClient_SObject* SALOMEDS_StudyManager::Paste(SALOMEDSClient_SObject* the { SALOMEDS_SObject* aSO = dynamic_cast(theSO); //SRN: Pure CORBA call as SALOMEDS::Driver required for this method - SALOMEDS_SObject* aResultSO = new SALOMEDS_SObject(_corba_impl->Paste(aSO->GetCORBAImpl())); + SALOMEDS::SObject_var aSO_impl = _corba_impl->Paste(aSO->GetCORBAImpl()); + if(CORBA::is_nil(aSO_impl)) return NULL; + SALOMEDS_SObject* aResultSO = new SALOMEDS_SObject(aSO_impl); return aResultSO; } -- 2.39.2