]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix crash in salome_test.py
authorvsr <vsr@opencascade.com>
Wed, 28 Aug 2013 11:00:25 +0000 (11:00 +0000)
committervsr <vsr@opencascade.com>
Wed, 28 Aug 2013 11:00:25 +0000 (11:00 +0000)
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx

index 85ab4def0c739ade356e8d1da92054fc40247afc..9cf0613dff73f59633c48f1550da87b1aeaf2ed7 100644 (file)
@@ -478,10 +478,19 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theSt
     return SALOMEDS::SComponent::_nil();
   if(MYDEBUG) MESSAGE("PublishComponent");
 
+  SALOMEDS::StudyBuilder_var   aStudyBuilder  = theStudy->NewBuilder(); 
+  SALOMEDS::UseCaseBuilder_var useCaseBuilder = theStudy->GetUseCaseBuilder();
+
   CORBA::String_var   compDataType = ComponentDataType();
   SALOMEDS::SComponent_wrap father = theStudy->FindComponent( compDataType.in() );
-  if ( !CORBA::is_nil( father ) )
+  if ( !CORBA::is_nil( father ) ) {
+    // check that the component is added to the use case browser
+    if ( !useCaseBuilder->IsUseCaseNode( father ) ) {
+      useCaseBuilder->SetRootCurrent();
+      useCaseBuilder->Append( father ); // component object is added as the top level item
+    }
     return father._retn();
+  }
 
   SALOME_ModuleCatalog::ModuleCatalog_var aCat =
     SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") );
@@ -492,8 +501,6 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theSt
   if ( CORBA::is_nil( aComp ) )
     return father._retn();
 
-  SALOMEDS::StudyBuilder_var      aStudyBuilder = theStudy->NewBuilder(); 
-  SALOMEDS::UseCaseBuilder_var    useCaseBuilder = theStudy->GetUseCaseBuilder();
   SALOMEDS::GenericAttribute_wrap anAttr;
   SALOMEDS::AttributePixMap_wrap  aPixmap;
 
index c97dd01fd81ea7212aa43a09d6f12b3a8278f45a..593855b72672a85df1988740ddcff5c5a41c6fc1 100644 (file)
@@ -380,6 +380,10 @@ SMESH_Swig::Init(int theStudyID)
         aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
         aPixmap->UnRegister();
 
+       SALOMEDS::UseCaseBuilder_var useCaseBuilder = myStudy->GetUseCaseBuilder();
+       useCaseBuilder->SetRootCurrent();
+       useCaseBuilder->Append( aSComponent.in() );
+  
         myStudyBuilder->DefineComponentInstance(aSComponent,aSMESHGen);
         if (aLocked)
           myStudy->GetProperties()->SetLocked(true);