if (myDisplayer)
delete myDisplayer;
+ myOperation->Destroy();
}
//================================================================
else {
for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it )
{
- displayPreview( *it, true, activate, false, lineWidth, displayMode, color );
+ GEOM::GEOM_Object_var obj=*it;
+ displayPreview( obj, true, activate, false, lineWidth, displayMode, color );
if ( toRemoveFromEngine )
- getGeomEngine()->RemoveObject( *it );
+ obj->Destroy();
}
}
}
// Each dialog is responsible for this method implementation,
// default implementation does nothing
restoreSubShapes(aStudyDS, aSO);
+ aSO->Destroy();
}
//================================================================
return false;
myCommand->abort();
+ delete myCommand; // I don't know where to delete this object here ?
myCommand = 0;
return true;
return false;
myCommand->commit();
+ delete myCommand; // I don't know where to delete this object here ?
myCommand = 0;
return true;
const int nbObjs = objects.size();
int aNumber = 1;
for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
+ GEOM::GEOM_Object_var obj=*it;
if ( publish ) {
QString aName = getNewObjectName();
if ( nbObjs > 1 ) {
if (aName.isEmpty())
- aName = getPrefix(*it);
+ aName = getPrefix(obj);
if (nbObjs <= 30) {
// Try to find a unique name
aName = GEOMBase::GetDefaultName(aName);
} else {
// PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
if ( aName.isEmpty() )
- aName = GEOMBase::GetDefaultName( getPrefix( *it ) );
+ aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
}
- addInStudy( *it, aName.toLatin1().constData() );
+ addInStudy( obj, aName.toLatin1().constData() );
// updateView=false
- display( *it, false );
+ display( obj, false );
+ // obj has been published in study. Its refcount has been incremented.
+ // It is safe to decrement its refcount
+ // so that it will be destroyed when the entry in study will be removed
+ obj->Destroy();
}
else {
// asv : fix of PAL6454. If publish==false, then the original shape
// was modified, and need to be re-cached in GEOM_Client before redisplay
- clearShapeBuffer( *it );
+ clearShapeBuffer( obj );
// withChildren=true, updateView=false
- redisplay( *it, true, false );
+ redisplay( obj, true, false );
}
}
anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName");
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue("Geometry");
+ aName->Destroy();
anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributePixMap");
- SALOMEDS::AttributePixMap::_narrow(anAttr)->SetPixMap("ICON_OBJBROWSER_Geometry");
- aStudyBuilder->DefineComponentInstance(aFather, GEOM_Gen::_this());
+ SALOMEDS::AttributePixMap_var aPixMap=SALOMEDS::AttributePixMap::_narrow(anAttr);
+ aPixMap->SetPixMap("ICON_OBJBROWSER_Geometry");
+ aPixMap->Destroy();
+ aStudyBuilder->DefineComponentInstance(aFather, (GEOM::GEOM_Gen_var)GEOM_Gen::_this());
}
if (aFather->_is_nil()) return aResultSO;
}
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- //char *aGeomObjIOR = _orb->object_to_string(theObject);
- CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject);
- //anIOR->SetValue(CORBA::string_dup(aGeomObjIOR));
+ CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject);
anIOR->SetValue(aGeomObjIOR);
+ anIOR->Destroy();
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
aShapeName = "Vertex_";
}
+ aPixmap->Destroy();
//if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
//else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName));
Handle(GEOM_Object) aGShape = _impl->GetObject(aShape->GetStudyID(), entry);
TopoDS_Shape TopoSh = aGShape->GetValue();
// find label of main shape
- GEOM::GEOM_Object_var aMainShVar = aShape;
- GEOM::GEOM_Object_ptr aMainSh = aMainShVar._retn();
+ GEOM::GEOM_Object_var aMainSh = aShape;
while( !aMainSh->IsMainShape() ) {
aMainSh = aMainSh->GetMainShape();
}
}
//Set the study entry as a name of the published GEOM_Object
- aShape->SetStudyEntry(aResultSO->GetID());
+ CORBA::String_var anID =aResultSO->GetID();
+ aShape->SetStudyEntry(anID.in());
//Set a name of the added shape
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
aNameAttrib->SetValue(aShapeName.ToCString());
+ aNameAttrib->Destroy();
//Set NoteBook variables used in the object creation
TCollection_AsciiString aVars;
- SALOMEDS::ListOfListOfStrings_var aSections = theStudy->ParseVariables(aShape->GetParameters());
+ CORBA::String_var aString=aShape->GetParameters();
+ SALOMEDS::ListOfListOfStrings_var aSections = theStudy->ParseVariables(aString);
for(int i = 0, n = aSections->length(); i < n; i++) {
SALOMEDS::ListOfStrings aListOfVars = aSections[i];
for(int j = 0, m = aListOfVars.length(); j < m; j++) {
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeString");
SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow(anAttr);
aStringAttrib->SetValue(aVars.ToCString());
+ aStringAttrib->Destroy();
+
+ aFather->Destroy();
//Set a name of the GEOM object
aShape->SetName(theName);
//============================================================================
void GEOM_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
{
- _impl->Close(theComponent->GetStudy()->StudyId());
+ SALOMEDS::Study_var aStudy= theComponent->GetStudy();
+ _impl->Close(aStudy->StudyId());
}
//============================================================================
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(anIOR->Value()));
+ CORBA::String_var aString=anIOR->Value();
+ anIOR->Destroy();
+ CORBA::Object_var anObj = _orb->string_to_object(aString);
+ GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(anObj);
// If the object is null one it can't be copied: return false
if (anObject->_is_nil()) return false;
return true;
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var objStr = _orb->object_to_string(obj);
anIOR->SetValue(objStr.in());
+ anIOR->Destroy();
// Return the created in the Study SObject
return aNewSO._retn();
SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR.in());
if(aFatherSO->_is_nil()) return aResultSO._retn();
aResultSO = aStudyBuilder->NewObject(aFatherSO);
+ aFatherSO->Destroy();
//aStudyBuilder->Addreference(aResultSO, aResultSO);
}
if(aSO->_is_nil()) continue;
SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO);
aStudyBuilder->Addreference(aSubSO, aSO);
+ aSO->Destroy();
+ aSubSO->Destroy();
}
return aResultSO._retn();
// return aParts._retn();
aParts = RestoreSubShapes(theStudy, theObject, aSO, theArgs, theFindMethod, theInheritFirstArg);
+ aSO->Destroy();
return aParts._retn();
}
// set the color of the transformed shape to the color of initial shape
theObject->SetColor(aList[0]->GetColor());
+ anArgSO->Destroy();
}
else {
// Get interface, containing method, which we will use to reconstruct sub-shapes
// Publish the sub-shape
SALOMEDS::SObject_var aSubSO;
- if (!CORBA::is_nil(theSObject)) {
+ if (!CORBA::is_nil(theSObject)) {
TCollection_AsciiString aSubName ("from_");
aSubName += anArgName;
aSubSO = aStudyBuilder->NewObject(theSObject);
else { // GetInPlace failed, try to build from published parts
if (!CORBA::is_nil(anArgSO)) {
SALOMEDS::SObject_var aSubSO;
- if (!CORBA::is_nil(theSObject))
+ if (!CORBA::is_nil(theSObject))
aSubSO = aStudyBuilder->NewObject(theSObject);
// Restore published sub-shapes of the argument
}
}
} // try to build from published parts
+ anArgSO->Destroy();
}
} // process arguments
}
GEOM_IBasicOperations_i* aServant =
new GEOM_IBasicOperations_i(_poa, engine, _impl->GetIBasicOperations(theStudyID));
+ PortableServer::ObjectId_var id = _poa->activate_object(aServant);
// activate the CORBA servant
GEOM::GEOM_IBasicOperations_var operations = aServant->_this();
return operations._retn();
GEOM_I3DPrimOperations_i* aServant =
new GEOM_I3DPrimOperations_i(_poa, engine, _impl->GetI3DPrimOperations(theStudyID));
+ PortableServer::ObjectId_var id = _poa->activate_object(aServant);
// activate the CORBA servant
GEOM::GEOM_I3DPrimOperations_var operations = aServant->_this();
}
GEOM::GEOM_Gen_ptr engine = _this();
+ //transfer the reference to GEOM_Object_i
GEOM_Object_i* servant = new GEOM_Object_i (_poa, engine, handle_object);
+ PortableServer::ObjectId_var id = _poa->activate_object(servant);
obj = servant->_this();
CORBA::String_var objStr = _orb->object_to_string(obj);
if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var aVal = anIOR->Value();
+ anIOR->Destroy();
CORBA::Object_var anObject = aStudy->ConvertIORToObject(aVal);
aGeomObject = GEOM::GEOM_Object::_narrow(anObject);
}
+ if (!aSObj->_is_nil() )
+ aSObj->Destroy();
const char* aTypeInfo = "Object";
if ( !aGeomObject->_is_nil() ) {
//=====================================================================================
extern "C"
{
+PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB*, PortableServer::POA*, PortableServer::ObjectId*, const char*, const char*);
+
GEOM_I_EXPORT
PortableServer::ObjectId * GEOMEngine_factory(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,