From de90c1e079d6705afaee69bead1b68ea1b530a25 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 1 Feb 2006 16:33:26 +0000 Subject: [PATCH] Fix for Bug IPAL11212 omniORB Error and AttributeError To call Destroy method on RemoveFromStudy --- src/VISU_I/VISUConfig.cc | 20 +++-------- src/VISU_I/VISU_ColoredPrs3d_i.cc | 22 ++++++++++-- src/VISU_I/VISU_Gen_i.cc | 54 ++-------------------------- src/VISU_I/VISU_Mesh_i.cc | 22 ++++++++++-- src/VISU_I/VISU_Mesh_i.hh | 8 ++++- src/VISU_I/VISU_Prs3d_i.cc | 27 +++++++++++++- src/VISU_I/VISU_Result_i.cc | 19 ++++++++-- src/VISU_I/VISU_Table_i.cc | 60 ++++++++++++++++++++++++++++--- src/VISU_I/VISU_Table_i.hh | 2 ++ 9 files changed, 154 insertions(+), 80 deletions(-) diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 56ef09c5..ee879b6a 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -432,13 +432,6 @@ namespace VISU{ if (CORBA::is_nil(aRemovableObject)) continue; aRemovableObject->RemoveFromStudy(); - - // Destroy - if (theDestroySubObjects) { - VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aRemovableObject); - if (CORBA::is_nil(aPrs3d)) continue; - aPrs3d->Destroy(); - } } // asl, fix for PAL10455: Remove references to SObject @@ -475,19 +468,14 @@ namespace VISU{ for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) { _PTR(SObject) aChildSObject = aChildIter->Value(); CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject); - if (CORBA::is_nil(aChildObj)) continue; + if (CORBA::is_nil(aChildObj)) + continue; VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(aChildObj); - if (CORBA::is_nil(aRemovableObject)) continue; + if (CORBA::is_nil(aRemovableObject)) + continue; aRemovableObject->RemoveFromStudy(); - - // Destroy - if (theDestroySubObjects) { - VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aRemovableObject); - if (CORBA::is_nil(aPrs3d)) continue; - aPrs3d->Destroy(); - } } // Remove the SObject itself diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 94b2e9d1..9cb3840c 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -31,6 +31,7 @@ #include "VISU_Convertor.hxx" #include "SUIT_ResourceMgr.h" +#include "SALOME_Event.hxx" #include @@ -68,14 +69,31 @@ VISU::ColoredPrs3d_i ::~ColoredPrs3d_i() {} +//--------------------------------------------------------------- void VISU::ColoredPrs3d_i ::RemoveFromStudy() { - TSuperClass::RemoveFromStudy(); - VISU::RemoveFromStudy(mySObject,false); + struct TRemoveFromStudy: public SALOME_Event + { + VISU::ColoredPrs3d_i* myRemovable; + TRemoveFromStudy(VISU::ColoredPrs3d_i* theRemovable): + myRemovable(theRemovable) + {} + + virtual + void + Execute() + { + myRemovable->TSuperClass::RemoveFromStudy(); + VISU::RemoveFromStudy(myRemovable->GetSObject(),false); + } + }; + + ProcessVoidEvent(new TRemoveFromStudy(this)); } +//--------------------------------------------------------------- void VISU::ColoredPrs3d_i ::SameAs(const Prs3d_i* theOrigin) diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 46094327..bf51d9b3 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -778,62 +778,12 @@ namespace VISU void VISU_Gen_i::DeleteResult (Result_ptr theResult) { - class TEvent: public SALOME_Event { - Result_ptr myResult; - public: - TEvent(Result_ptr theResult): myResult(theResult) {} - virtual void Execute() - { - if (Result_i* aResult = dynamic_cast(GetServant(myResult).in())) { - SALOMEDS::SObject_var aSObject = aResult->GetSObject(); - VISU::RemoveFromStudy(aSObject, - false, // not only attribute - true); // destroy sub-objects - - //jfa tmp:if (QAD_Desktop* aDesktop = QAD_Application::getDesktop()) - //jfa tmp: if (QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)) - //jfa tmp: aStudy->updateObjBrowser(); //update Object browser - } - - myResult->Destroy(); - } - }; - - if (myStudyDocument->GetProperties()->IsLocked()) - return; - Mutex mt(myMutex); // jfa ??? - - ProcessVoidEvent(new TEvent(theResult)); + theResult->RemoveFromStudy(); } void VISU_Gen_i::DeletePrs3d (Prs3d_ptr thePrs3d) { - class TEvent: public SALOME_Event { - Prs3d_ptr myPrs3d; - public: - TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {} - virtual void Execute() { - myPrs3d->RemoveFromStudy(); - - //update Object browser - /*jfa tmp:if (QAD_Desktop* aDesktop = QAD_Application::getDesktop()) { - if (Prs3d_i* aPrs3d = dynamic_cast(GetServant(myPrs3d).in())) { - SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject(); - SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy(); - if (QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)) - aStudy->updateObjBrowser(); - } - }*/ - - myPrs3d->Destroy(); - } - }; - - if (myStudyDocument->GetProperties()->IsLocked()) - return; - Mutex mt(myMutex); // jfa ??? - - ProcessVoidEvent(new TEvent(thePrs3d)); + thePrs3d->RemoveFromStudy(); } void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){ diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 701e27eb..90b9b1ce 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -33,6 +33,8 @@ #include "VISU_MeshPL.hxx" #include "VISU_Convertor.hxx" +#include "SALOME_Event.hxx" + using namespace VISU; using namespace std; @@ -73,10 +75,26 @@ Mesh_i(Result_i* theResult, } +//--------------------------------------------------------------- void VISU::Mesh_i::RemoveFromStudy() { - VISU::Prs3d_i::RemoveFromStudy(); - VISU::RemoveFromStudy(mySObject); + struct TRemoveFromStudy: public SALOME_Event + { + VISU::Mesh_i* myRemovable; + TRemoveFromStudy(VISU::Mesh_i* theRemovable): + myRemovable(theRemovable) + {} + + virtual + void + Execute() + { + myRemovable->TSuperClass::RemoveFromStudy(); + VISU::RemoveFromStudy(myRemovable->GetSObject()); + } + }; + + ProcessVoidEvent(new TRemoveFromStudy(this)); } diff --git a/src/VISU_I/VISU_Mesh_i.hh b/src/VISU_I/VISU_Mesh_i.hh index a9eb6f7e..4bb0809e 100644 --- a/src/VISU_I/VISU_Mesh_i.hh +++ b/src/VISU_I/VISU_Mesh_i.hh @@ -31,19 +31,25 @@ class VISU_MeshPL; -namespace VISU{ +namespace VISU +{ class Mesh_i : public virtual POA_VISU::Mesh, public virtual Prs3d_i { static int myNbPresent; Mesh_i(); Mesh_i(const Mesh_i&); + public: + typedef Prs3d_i TSuperClass; + explicit Mesh_i(Result_i* theResult); + explicit Mesh_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject); + virtual void SameAs(const Prs3d_i* theOrigin); virtual ~Mesh_i(); virtual void RemoveFromStudy(); diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index f0d97655..32338e4d 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -30,6 +30,8 @@ #include "VISU_Result_i.hh" #include "VISU_Actor.h" +#include "SALOME_Event.hxx" + #include #include @@ -163,11 +165,34 @@ VISU::Prs3d_i } } + +//---------------------------------------------------------------------------- void VISU::Prs3d_i ::RemoveFromStudy() { - myRemoveActorsFromRendererSignal(); + struct TRemoveFromStudy: public SALOME_Event + { + VISU::Prs3d_i* myRemovable; + typedef boost::signal0 TRemoveFromStudySignal; + const TRemoveFromStudySignal& myRemoveFromStudySignal; + + TRemoveFromStudy(VISU::Prs3d_i* theRemovable, + const TRemoveFromStudySignal& theRemoveFromStudySignal): + myRemovable(theRemovable), + myRemoveFromStudySignal(theRemoveFromStudySignal) + {} + + virtual + void + Execute() + { + myRemoveFromStudySignal(); + myRemovable->Destroy(); + } + }; + + ProcessVoidEvent(new TRemoveFromStudy(this,myRemoveActorsFromRendererSignal)); } diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index f16ae64c..63b10905 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -811,9 +811,24 @@ void VISU::Result_i ::RemoveFromStudy() { + struct TRemoveFromStudy: public SALOME_Event + { + VISU::Result_i* myRemovable; + TRemoveFromStudy(VISU::Result_i* theRemovable): + myRemovable(theRemovable) + {} + + virtual + void + Execute() + { + VISU::RemoveFromStudy(myRemovable->GetSObject(),false); + myRemovable->Destroy(); + } + }; + // Remove the result with all presentations and other possible sub-objects - VISU::RemoveFromStudy(mySObject,false); - Destroy(); + ProcessVoidEvent(new TRemoveFromStudy(this)); } diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index dfe598c1..00e6a6f9 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -30,6 +30,7 @@ #include "VISU_Result_i.hh" #include "VISU_ViewManager_i.hh" +#include "SALOME_Event.hxx" #include "SPlot2d_Curve.h" #include @@ -269,10 +270,26 @@ const char* VISU::Table_i::GetTableTitle() return ""; } +//--------------------------------------------------------------- void VISU::Table_i::RemoveFromStudy() { + struct TRemoveFromStudy: public SALOME_Event + { + VISU::Table_i* myRemovable; + TRemoveFromStudy(VISU::Table_i* theRemovable): + myRemovable(theRemovable) + {} + + virtual + void + Execute() + { + VISU::RemoveFromStudy(myRemovable->GetSObject(),false); + } + }; + // Remove the table with all curves - VISU::RemoveFromStudy(mySObj,false); + ProcessVoidEvent(new TRemoveFromStudy(this)); } //---------------------------------------------------------------- @@ -669,8 +686,23 @@ VISU::Storable* VISU::Curve_i::Restore(SALOMEDS::SObject_ptr theSObject, void VISU::Curve_i::RemoveFromStudy() { - VISU::DeleteActors(this); - VISU::RemoveFromStudy(mySObj,false); + struct TRemoveFromStudy: public SALOME_Event + { + VISU::Curve_i* myRemovable; + TRemoveFromStudy(VISU::Curve_i* theRemovable): + myRemovable(theRemovable) + {} + + virtual + void + Execute() + { + VISU::DeleteActors(myRemovable); + VISU::RemoveFromStudy(myRemovable->GetSObject(),false); + } + }; + + ProcessVoidEvent(new TRemoveFromStudy(this)); } SALOMEDS::SObject_var VISU::Curve_i::GetSObject() @@ -943,7 +975,27 @@ VISU::Storable* VISU::Container_i::Restore(SALOMEDS::SObject_ptr theSObject, void VISU::Container_i::RemoveFromStudy() { - VISU::RemoveFromStudy(mySObj,false); + struct TRemoveFromStudy: public SALOME_Event + { + VISU::Container_i* myRemovable; + TRemoveFromStudy(VISU::Container_i* theRemovable): + myRemovable(theRemovable) + {} + + virtual + void + Execute() + { + VISU::RemoveFromStudy(myRemovable->GetSObject(),false); + } + }; + + ProcessVoidEvent(new TRemoveFromStudy(this)); +} + +SALOMEDS::SObject_var VISU::Container_i::GetSObject() +{ + return mySObj; } //------------------------------------------------------------- diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index ed911dcf..608f5dfe 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -177,6 +177,8 @@ namespace VISU{ virtual void RemoveFromStudy(); + virtual SALOMEDS::SObject_var GetSObject(); + protected: Storable* Build(int theRestoring); -- 2.39.2