corrections to IPAL 22059 SIGSEGV on closing study

This commit is contained in:
dmv 2010-10-11 13:51:55 +00:00
parent b9038c7474
commit 60503363ee
7 changed files with 31 additions and 33 deletions

View File

@ -893,7 +893,7 @@ GEOM::GEOM_Object_ptr GEOMBase::GetObjectFromIOR( const char* theIOR )
// function : GetIORFromObject() // function : GetIORFromObject()
// purpose : returns IOR of a given GEOM_Object // purpose : returns IOR of a given GEOM_Object
//======================================================================= //=======================================================================
char* GEOMBase::GetIORFromObject( const GEOM::GEOM_Object_ptr& theObject ) QString GEOMBase::GetIORFromObject( const GEOM::GEOM_Object_ptr& theObject )
{ {
if ( CORBA::is_nil( theObject ) ) if ( CORBA::is_nil( theObject ) )
return NULL; return NULL;

View File

@ -90,7 +90,7 @@ public :
static GEOM::GEOM_Object_ptr GetObjectFromIOR(const char* theIOR); static GEOM::GEOM_Object_ptr GetObjectFromIOR(const char* theIOR);
static char* GetIORFromObject(const GEOM::GEOM_Object_ptr& theObject); static QString GetIORFromObject(const GEOM::GEOM_Object_ptr& theObject);
/* Geometry */ /* Geometry */
static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P); static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P);

View File

@ -170,9 +170,10 @@ void GEOMBase_Helper::erase( const ObjectList& objList, const bool updateView )
void GEOMBase_Helper::erase( GEOM::GEOM_Object_ptr object, const bool updateView ) void GEOMBase_Helper::erase( GEOM::GEOM_Object_ptr object, const bool updateView )
{ {
if ( !object->_is_nil() ) { if ( !object->_is_nil() ) {
std::string entry = getEntry( object ); QString entry = getEntry( object );
getDisplayer()->Erase( new SALOME_InteractiveObject( getDisplayer()->Erase( new SALOME_InteractiveObject(
entry.c_str(), "GEOM", strdup( GEOMBase::GetName( object ).toLatin1().constData() ) ), true, updateView ); entry.toLatin1().constData(),
"GEOM", strdup( GEOMBase::GetName( object ).toLatin1().constData() ) ), true, updateView );
} }
} }
@ -209,9 +210,9 @@ void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object,
// Enable activisation of selection // Enable activisation of selection
getDisplayer()->SetToActivate( true ); getDisplayer()->SetToActivate( true );
std::string entry = getEntry( object ); QString entry = getEntry( object );
getDisplayer()->Redisplay(new SALOME_InteractiveObject getDisplayer()->Redisplay(new SALOME_InteractiveObject
(entry.c_str(), "GEOM", strdup(GEOMBase::GetName(object).toLatin1().constData())), false); (entry.toLatin1().constData(), "GEOM", strdup(GEOMBase::GetName(object).toLatin1().constData())), false);
} }
if ( withChildren ) { if ( withChildren ) {
@ -227,9 +228,9 @@ void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object,
(GeometryGUI::ClientSObjectToObject(anIt->Value())); (GeometryGUI::ClientSObjectToObject(anIt->Value()));
if ( !CORBA::is_nil( aChild ) ) { if ( !CORBA::is_nil( aChild ) ) {
if ( !aChild->_is_nil() ) { if ( !aChild->_is_nil() ) {
std::string entry = getEntry( aChild ); QString entry = getEntry( aChild );
getDisplayer()->Redisplay( new SALOME_InteractiveObject( getDisplayer()->Redisplay( new SALOME_InteractiveObject(
entry.c_str(), "GEOM", strdup( GEOMBase::GetName( aChild ).toLatin1().constData() ) ), false ); entry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( aChild ).toLatin1().constData() ) ), false );
} }
} }
} }
@ -449,10 +450,10 @@ void GEOMBase_Helper::localSelection( const ObjectList& theObjs, const int theMo
GEOM::GEOM_Object_ptr anObj = *anIter; GEOM::GEOM_Object_ptr anObj = *anIter;
if ( anObj->_is_nil() ) if ( anObj->_is_nil() )
continue; continue;
std::string aEntry = getEntry( anObj ); QString anEntry = getEntry( anObj );
if ( aEntry != "" ) if ( anEntry != "" )
aListOfIO.Append( new SALOME_InteractiveObject( aListOfIO.Append( new SALOME_InteractiveObject(
aEntry.c_str(), "GEOM", strdup( GEOMBase::GetName( anObj ).toLatin1().constData() ) ) ); anEntry.toLatin1().constData(), "GEOM", strdup( GEOMBase::GetName( anObj ).toLatin1().constData() ) ) );
} }
getDisplayer()->LocalSelection( aListOfIO, theMode ); getDisplayer()->LocalSelection( aListOfIO, theMode );
@ -619,19 +620,18 @@ SalomeApp_Study* GEOMBase_Helper::getStudy() const
// Function : getEntry // Function : getEntry
// Purpose : // Purpose :
//================================================================ //================================================================
char* GEOMBase_Helper::getEntry( GEOM::GEOM_Object_ptr object ) const QString GEOMBase_Helper::getEntry( GEOM::GEOM_Object_ptr object ) const
{ {
SalomeApp_Study* study = getStudy(); SalomeApp_Study* study = getStudy();
if ( study ) { if ( study ) {
CORBA::String_var objIOR = GEOMBase::GetIORFromObject( object ); QString objIOR = GEOMBase::GetIORFromObject( object );
std::string IOR( objIOR ); if ( objIOR != "" ) {
if ( IOR != "" ) { _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( objIOR.toLatin1().constData() ) );
_PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
if ( SO ) if ( SO )
return (char*) TCollection_AsciiString((char*)SO->GetID().c_str()).ToCString(); return QString::fromStdString(SO->GetID());
} }
} }
return (char*)""; return "";
} }
//================================================================ //================================================================
@ -1023,9 +1023,8 @@ bool GEOMBase_Helper::selectObjects( ObjectList& objects )
ObjectList::iterator anIter; ObjectList::iterator anIter;
for ( anIter = objects.begin(); anIter != objects.end(); ++anIter ) for ( anIter = objects.begin(); anIter != objects.end(); ++anIter )
{ {
std::string entry = getEntry( *anIter ); QString anEntry = getEntry( *anIter );
QString aEntry( entry.c_str() ); LightApp_DataOwner* anOwher = new LightApp_DataOwner( anEntry );
LightApp_DataOwner* anOwher = new LightApp_DataOwner( aEntry );
aList.append( anOwher ); aList.append( anOwher );
} }
@ -1055,8 +1054,8 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather (GEOM::GEOM_Object_ptr
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
_PTR(Study) aDStudy = appStudy->studyDS(); _PTR(Study) aDStudy = appStudy->studyDS();
std::string IOR = GEOMBase::GetIORFromObject( theFather ); QString IOR = GEOMBase::GetIORFromObject( theFather );
_PTR(SObject) SObj ( aDStudy->FindObjectIOR( IOR ) ); _PTR(SObject) SObj ( aDStudy->FindObjectIOR( IOR.toLatin1().constData() ) );
bool inStudy = false; bool inStudy = false;
GEOM::GEOM_Object_var aReturnObject; GEOM::GEOM_Object_var aReturnObject;
@ -1102,7 +1101,7 @@ void GEOMBase_Helper::addSubshapesToFather( QMap<QString, GEOM::GEOM_Object_var>
if ( !anOp->_is_nil() ) { if ( !anOp->_is_nil() ) {
GEOM::GEOM_Object_var aFatherObj = anOp->GetMainShape( it.value() ); GEOM::GEOM_Object_var aFatherObj = anOp->GetMainShape( it.value() );
if ( !aFatherObj->_is_nil() ) { if ( !aFatherObj->_is_nil() ) {
std::string aFatherEntry = getEntry( aFatherObj ); QString aFatherEntry = getEntry( aFatherObj );
if ( aFatherEntry != "") { // additional checking that object is valid 0020598 EDF 1191 if ( aFatherEntry != "") { // additional checking that object is valid 0020598 EDF 1191
GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aFatherObj, it.key().toLatin1().data() ); GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aFatherObj, it.key().toLatin1().data() );
//Add Object to study if its not exist //Add Object to study if its not exist

View File

@ -177,7 +177,7 @@ protected:
SUIT_Desktop* getDesktop() const; SUIT_Desktop* getDesktop() const;
private: private:
char* getEntry ( GEOM::GEOM_Object_ptr ) const; QString getEntry( GEOM::GEOM_Object_ptr ) const;
void clearShapeBuffer( GEOM::GEOM_Object_ptr ); void clearShapeBuffer( GEOM::GEOM_Object_ptr );
private: private:

View File

@ -1059,10 +1059,9 @@ bool GroupGUI_GroupDlg::execute(ObjectList& objects)
SalomeApp_Study* study = getStudy(); SalomeApp_Study* study = getStudy();
if (study) { if (study) {
CORBA::String_var objIOR = GEOMBase::GetIORFromObject(aGroup); QString objIOR = GEOMBase::GetIORFromObject(aGroup);
std::string IOR(objIOR); if (objIOR != "") {
if (IOR != "") { _PTR(SObject) SO (study->studyDS()->FindObjectIOR(objIOR.toLatin1().constData()));
_PTR(SObject) SO (study->studyDS()->FindObjectIOR(IOR));
if (SO) { if (SO) {
_PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder()); _PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder());
aBuilder->SetName(SO, getNewObjectName().toLatin1().constData()); aBuilder->SetName(SO, getNewObjectName().toLatin1().constData());

View File

@ -177,8 +177,8 @@ bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax,
if ( CORBA::is_nil(aGeomGen) ) if ( CORBA::is_nil(aGeomGen) )
return false; return false;
CORBA::String_var IOR = GEOMBase::GetIORFromObject( myObj ); QString IOR = GEOMBase::GetIORFromObject( myObj );
GEOM::GEOM_Object_var anObject = aGeomGen->GetIORFromString(IOR); GEOM::GEOM_Object_var anObject = aGeomGen->GetIORFromString( IOR.toLatin1().constData() );
if ( CORBA::is_nil(anObject) ) if ( CORBA::is_nil(anObject) )
return false; return false;

View File

@ -246,8 +246,8 @@ void RepairGUI_SuppressFacesDlg::SelectionIntoArgument()
aSelMgr->clearSelected(); aSelMgr->clearSelected();
Standard_Boolean isOk; Standard_Boolean isOk;
CORBA::String_var objIOR = GEOMBase::GetIORFromObject(myObject); QString objIOR = GEOMBase::GetIORFromObject(myObject);
Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape(objIOR, isOk, true); Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape(objIOR.toLatin1().constData(), isOk, true);
if (!isOk || aSh.IsNull()) if (!isOk || aSh.IsNull())
return; return;