]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug IPAL11212
authorapo <apo@opencascade.com>
Wed, 1 Feb 2006 16:33:26 +0000 (16:33 +0000)
committerapo <apo@opencascade.com>
Wed, 1 Feb 2006 16:33:26 +0000 (16:33 +0000)
   omniORB Error and AttributeError
To call Destroy method on RemoveFromStudy

src/VISU_I/VISUConfig.cc
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Mesh_i.cc
src/VISU_I/VISU_Mesh_i.hh
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Table_i.cc
src/VISU_I/VISU_Table_i.hh

index 56ef09c5c0b1725a7c240de9b36378fc573ee5d7..ee879b6a407126e423413b4bc43c2c8cfa4ac77c 100644 (file)
@@ -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
index 94b2e9d15ecc23baa5a2e8372cb8376660ab8ed0..9cb3840c51af68dc641d4995a9385421d35cf90e 100644 (file)
@@ -31,6 +31,7 @@
 #include "VISU_Convertor.hxx"
 
 #include "SUIT_ResourceMgr.h"
+#include "SALOME_Event.hxx"
 
 #include <vtkMapper.h>
 
@@ -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)
index 46094327556f95c5b5224555e7b564b57d22e4e9..bf51d9b34e449fb8c4741f20949d88aa9af68e45 100644 (file)
@@ -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<Result_i*>(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<Prs3d_i*>(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){
index 701e27ebd8e1230d4a87342ed444ba50037cde2c..90b9b1ce18e7ddaed18ba36fe2e4f8fa9fbed3aa 100644 (file)
@@ -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));
 }
 
 
index a9eb6f7efdb51db3dfb4d6c4bf6ccd316bbcc193..4bb0809e5610bbbc117224bc05ab41375da6b6c6 100644 (file)
 
 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();
index f0d97655960e0de11a0900cb48b84c28fe860612..32338e4d0744c7f073ea5025d7944d37ea88c651 100644 (file)
@@ -30,6 +30,8 @@
 #include "VISU_Result_i.hh"
 #include "VISU_Actor.h"
 
+#include "SALOME_Event.hxx"
+
 #include <vtkActorCollection.h>
 #include <vtkMapper.h>
 
@@ -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<void> 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));
 }
 
 
index f16ae64cdef5dee3a50098a7fc255cdf15a638e1..63b1090511009eaea0ffe1766e76a3e3744f846e 100644 (file)
@@ -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));
 }
 
 
index dfe598c17574bfcdcd45796b99cff850082fe3c1..00e6a6f9512b296308a501ee889823cd491e980a 100644 (file)
@@ -30,6 +30,7 @@
 #include "VISU_Result_i.hh"
 #include "VISU_ViewManager_i.hh"
 
+#include "SALOME_Event.hxx"
 #include "SPlot2d_Curve.h"
 
 #include <memory>
@@ -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;
 }
 
 //-------------------------------------------------------------
index ed911dcfaee60ad70af754ec0ec1ebd3c2244df5..608f5dfe0f13b59673eb2ed7183f3f2c3d1988b5 100644 (file)
@@ -177,6 +177,8 @@ namespace VISU{
 
     virtual void RemoveFromStudy();
 
+    virtual SALOMEDS::SObject_var GetSObject();
+
   protected:
     Storable* Build(int theRestoring);