]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
0021403: EDF 1972 VISU: Crash when dumping study
authoreap <eap@opencascade.com>
Wed, 23 Nov 2011 15:44:41 +0000 (15:44 +0000)
committereap <eap@opencascade.com>
Wed, 23 Nov 2011 15:44:41 +0000 (15:44 +0000)
   Remove a ColoredPrs3dHolder if a Result it refers to is removed

src/VISU_I/VISU_Result_i.cc

index a49ff289ffea2ea876ffdf24d864c0febc691be9..e3058e7a02402172d01bdb16d25654eb8d0a9675 100644 (file)
@@ -141,6 +141,31 @@ namespace VISU
     aStudyBuilder->Addreference(newObj,aRefSObj);
   }
 
+  //---------------------------------------------------------------
+  // Issue 0021403. Remove a ColoredPrs3dHolder if a Result it refers to is removed
+  //
+  void RemoveHolders(VISU::Result_i* theResult)
+  {
+    CORBA::String_var resultID1 = theResult->GetID();
+    SALOMEDS::SObject_var theResSObject = theResult->GetSObject();
+    SALOMEDS::Study_var aStudyDocument = theResSObject->GetStudy();
+    SALOMEDS::SComponent_var aCompSObj = theResSObject->GetFatherComponent();
+    SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aCompSObj);
+    for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next())
+    {
+      SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+      if ( CORBA::is_nil( aChildSObject )) continue;
+      CORBA::Object_var aChildObj = aChildSObject->GetObject();
+      if ( CORBA::is_nil( aChildObj )) continue;
+      VISU::ColoredPrs3dHolder_var prsHolder = ColoredPrs3dHolder::_narrow( aChildObj );
+      if ( prsHolder->_is_nil() ) continue;
+      // check if the prsHolder refers to theResult
+      VISU::ColoredPrs3dHolder::BasicInput_var input = prsHolder->GetBasicInput();
+      CORBA::String_var resultID2 = input->myResult->GetID();
+      if ( strcmp( resultID1, resultID2 ) == 0 )
+        prsHolder->RemoveFromStudy();
+    }
+  }
 
 //---------------------------------------------------------------
 }
@@ -220,6 +245,7 @@ VISU::Result_i
     void
     Execute()
     {
+      RemoveHolders(myRemovable); 
       VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
       myRemovable->UnRegister();
     }