Handle(TDataStd_Name) aNameAttr;
if(!_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) return NULL;
+ // do not
TCollection_AsciiString aName(aNameAttr->Get());
- return aName.ToCString();
+ // do not return pointer of local variable
+ // return aName.ToCString();
+ // the following code could lead to memory leak, so take care about recieved pointer
+ return strdup(aName.ToCString());
}
//=============================================================================
if ( appStudy )
{
- string anIOR = SalomeApp_Application::orb()->object_to_string( theObj );
- if ( anIOR != "" )
+ CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( theObj );
+ if ( strcmp(anIOR.in(), "") != 0 )
{
- _PTR(SObject) aSObj ( appStudy->studyDS()->FindObjectIOR( anIOR ) );
+ _PTR(SObject) aSObj ( appStudy->studyDS()->FindObjectIOR( string( anIOR ) ) );
_PTR(GenericAttribute) anAttr;
SalomeApp_Study* aDoc = getStudy();
if ( aDoc && aDoc->studyDS() ) {
_PTR(Study) aStudy = aDoc->studyDS();
- _PTR(SObject) aSObj (aStudy->FindObjectIOR(SalomeApp_Application::orb()->object_to_string(object)));
+ CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(object);
+ _PTR(SObject) aSObj (aStudy->FindObjectIOR(string(objStr.in())));
if ( aSObj ) {
_PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
getDisplayer()->SetToActivate( activate );
// Make a reference to GEOM_Object
- getDisplayer()->SetName( SalomeApp_Application::orb()->object_to_string( object ) );
+ CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string( object );
+ getDisplayer()->SetName( objStr.in() );
// Build prs
SALOME_Prs* aPrs = getDisplayer()->BuildPrs( object );
{
SalomeApp_Study* study = getStudy();
if ( study ) {
- string IOR = GEOMBase::GetIORFromObject( object);
+ char * objIOR = GEOMBase::GetIORFromObject( object );
+ string IOR( objIOR );
+ free( objIOR );
if ( IOR != "" ) {
_PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
if ( SO ) {
- return TCollection_AsciiString((char*)SO->GetID().c_str()).ToCString();
+ return TCollection_AsciiString((char*)SO->GetID().c_str()).ToCString();
}
}
}
if ( CORBA::is_nil( theObj ) )
return;
- string IOR = SalomeApp_Application::orb()->object_to_string( theObj );
- TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) );
+ CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
+ TCollection_AsciiString asciiIOR( (char *)IOR.in() );
GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
if ( !getStudy() || !getStudy()->studyDS() )
return;
_PTR(Study) aStudy = getStudy()->studyDS();
- _PTR(SObject) aSObj ( aStudy->FindObjectIOR( IOR ) );
+ _PTR(SObject) aSObj ( aStudy->FindObjectIOR( string( IOR ) ) );
if ( !aSObj )
return;
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
if ( app )
{
- string IOR = app->orb()->object_to_string( object );
- if ( IOR != "" )
+ CORBA::String_var IOR = app->orb()->object_to_string( object );
+ if ( strcmp(IOR.in(), "") != 0 )
{
SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
- _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
+ _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( string(IOR) ) );
if ( SO )
return SO->GetID();
}
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
if ( app )
{
- string IOR = app->orb()->object_to_string( object );
- if ( IOR != "" )
+ CORBA::String_var IOR = app->orb()->object_to_string( object );
+ if ( strcmp(IOR.in(), "") != 0 )
{
SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
- _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( IOR ) );
+ _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( string(IOR) ) );
_PTR(GenericAttribute) anAttr;
QString GeometryGUI::engineIOR() const
{
+ QString anIOR = QString::null;
if ( !CORBA::is_nil( GetGeomGen() ) )
- return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
- return QString( "" );
+ {
+ CORBA::String_var objStr = getApp()->orb()->object_to_string( GetGeomGen() );
+ anIOR = QString( objStr.in() );
+ free( objStr );
+ }
+ return anIOR;
}
LightApp_Selection* GeometryGUI::createSelection() const
if (!father)
return;
if (!father->ComponentIOR(aFatherIOR)) {
- aStudyBuilder->LoadWith(father, SalomeApp_Application::orb()->object_to_string(Geom));
+ CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(Geom);
+ aStudyBuilder->LoadWith(father, objStr.in());
father->ComponentIOR(aFatherIOR);
}
// VSR 17/11/04: check if all objects selected belong to GEOM component --> start
// modifications of ASV 01.06.05
QString parentComp = getParentComponent( aStudy, selected );
- const char* geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
- QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR ) );
+ CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
+ QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR.in() ) );
if ( parentComp != geomComp ) {
SUIT_MessageBox::warn1 ( app->desktop(),
GEOM::GEOM_Object_var obj = GetObject(anObject->GetDocID(), anEntry.ToCString());
CORBA::String_var aPersRefString = _orb->object_to_string(obj);
- return strdup(aPersRefString);
+ return strdup(aPersRefString.in());
}
//============================================================================
}
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- char *aGeomObjIOR = _orb->object_to_string(theObject);
- anIOR->SetValue(strdup(aGeomObjIOR));
+ CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject);
+ anIOR->SetValue( aGeomObjIOR .in() );
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aShapeName = "Vertex_";
}
//if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
- //else aShapeName = TCollection_AsciiString(strdup(theName));
+ //else aShapeName = TCollection_AsciiString((char *)theName);
// asv : 11.11.04 Introducing a more sofisticated method of name creation, just as
// it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number
if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
SALOMEDS::Study_var Study = theComponent->GetStudy();
- TCollection_AsciiString name( strdup(Study->Name()) );
+ TCollection_AsciiString name( (char *)(Study->Name() ) );
return true;
}
// Add IORAttribute to the Study and set IOR of the created GEOM_Object to it
SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSO, "AttributeIOR");
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- anIOR->SetValue(_orb->object_to_string(obj));
+ CORBA::String_var objStr = _orb->object_to_string(obj);
+ anIOR->SetValue(objStr.in());
// Return the created in the Study SObject
return aNewSO._retn();
if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO;
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
- char* IOR;
+ CORBA::String_var IOR;
if(!theFather->_is_nil()) {
IOR = _orb->object_to_string(theFather);
- SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR);
+ SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR.in());
if(aFatherSO->_is_nil()) return aResultSO._retn();
aResultSO = aStudyBuilder->NewObject(aFatherSO);
//aStudyBuilder->Addreference(aResultSO, aResultSO);
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);
+ SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(IOR.in());
if(aSO->_is_nil()) continue;
SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO);
aStudyBuilder->Addreference(aSubSO, aSO);
//============================================================================
void GEOM_Gen_i::register_name(char * name)
{
- GEOM::GEOM_Gen_ptr g = GEOM::GEOM_Gen::_narrow(_this());
- name_service->Register(g, strdup(name));
+ CORBA::Object_var obj = _this();
+ GEOM::GEOM_Gen_var g = GEOM::GEOM_Gen::_narrow(obj);
+ name_service->Register(g, name);
}
//============================================================================
GEOM_Object_i* servant = new GEOM_Object_i (_poa, engine, handle_object);
obj = servant->_this();
- stringIOR = _orb->object_to_string(obj);
- handle_object->SetIOR(stringIOR);
+ CORBA::String_var objStr = _orb->object_to_string(obj);
+ TCollection_AsciiString anAscii( (char *)objStr.in() );
+ handle_object->SetIOR( anAscii );
return obj._retn();
}
GEOM_IOperations_i::GEOM_IOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOM_IOperations* theImpl)
:SALOME::GenericObj_i( thePOA ), _impl(theImpl), _engine(theEngine)
{
- // Win32 porting: the next line is dangerous - GEOM_IOperations_i is an intermediate
- // base class, therefore <this> is not completely constructed here ->
- // passing it to activate_object() leads to unpredictable behavior
- // resulted from memory corruption ( Rational Purify reports ABR errors ).
- // Moreover, all GEOM_IxxxOperation_i servant classes are activated implicitly
- // by GEOM_Gen_i::GetxxxOperations() methods.
- // Therefore, this line is commented.
- // In case if <thePOA> does not have ImplicitActivation policy, then
- // activate_object() calls will be necessary in all GEOM_IxxxOperation_i constructors!
- //thePOA->activate_object(this);
}
//=============================================================================
Handle(GEOM_Object) theImpl)
: SALOME::GenericObj_i( thePOA ), _engine(theEngine), _impl(theImpl)
{
- thePOA->activate_object(this);
}
//=============================================================================
const TDF_Label& aLabel = _impl->GetEntry();
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aLabel, anEntry);
- return CORBA::string_dup(anEntry.ToCString());
+ const char* anEntstr = anEntry.ToCString();
+ return CORBA::string_dup(anEntstr);
}
//=============================================================================
char* GEOM_Object_i::GetName()
{
char* aName = _impl->GetName();
- if(aName) return strdup(aName);
+ if (aName)
+ return aName; // this is already copy of pointer (see implementation of _impl)
return strdup("");
}
if ( isNewStudy(myLastStudyID,myStudyID) ) {
if (CORBA::is_nil(myGeomEngine)) setGeomEngine();
- string anEngine = _orb->object_to_string( myGeomEngine );
+ CORBA::String_var anEngine = _orb->object_to_string( myGeomEngine );
CORBA::Object_var anObj = name_service->Resolve("/myStudyManager");
if ( !CORBA::is_nil(anObj) ) {
_PTR(SComponent) aSCO = aDSStudy->FindComponent(myGeomEngine->ComponentDataType());
if ( aSCO ) {
_PTR(StudyBuilder) aBuilder = aDSStudy->NewBuilder();
- if ( aBuilder ) aBuilder->LoadWith( aSCO, anEngine );
+ if ( aBuilder ) aBuilder->LoadWith( aSCO, string( anEngine.in() ) );
}
}
}
return;
Standard_Boolean isOk;
+ char* objIOR = GEOMBase::GetIORFromObject( myMainObj );
Handle(GEOM_AISShape) aSh =
- GEOMBase::ConvertIORinGEOMAISShape( GEOMBase::GetIORFromObject( myMainObj ), isOk, true );
+ GEOMBase::ConvertIORinGEOMAISShape( objIOR, isOk, true );
+ free( objIOR );
if ( !isOk || aSh.IsNull() )
return;
SalomeApp_Study* study = getStudy();
if ( study ) {
- string IOR = GEOMBase::GetIORFromObject( aGroup );
+ char* objIOR = GEOMBase::GetIORFromObject( aGroup );
+ string IOR( objIOR );
+ free( objIOR );
if ( IOR != "" ) {
_PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
if ( SO ) {
if ( CORBA::is_nil( theObj ) )
return;
- string IOR = myGeomGUI->getApp()->orb()->object_to_string( theObj );
- TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) );
+ CORBA::String_var IOR = myGeomGUI->getApp()->orb()->object_to_string( theObj );
+ TCollection_AsciiString asciiIOR( (char *)( IOR.in() ) );
myGeomGUI->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );
if ( !getStudy() || !( getStudy()->studyDS() ) )
return;
_PTR(Study) aStudy = getStudy()->studyDS();
- _PTR(SObject) aSObj ( aStudy->FindObjectIOR( IOR ) );
+ _PTR(SObject) aSObj ( aStudy->FindObjectIOR( string( IOR.in() ) ) );
if ( !aSObj )
return;