Salome HOME
Regression: mesh objects are not deleted => memory leaks
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i_1.cxx
index a73f93c3c0417fcd49ad3dd738dc02fb01b7f0aa..1b1ccc4ea17c27c13d7974682a5a9b1edca3a87a 100644 (file)
@@ -308,10 +308,12 @@ static SALOMEDS::SObject_ptr publish(CORBA::Object_ptr     theIOR,
     if ( !sameIOR )
     {
       iorAttr->SetValue( objStr.in() );
-      // UnRegister() !!! --> No: random problems when meshing in parallel (yacs foreach) in distributed python scripts
-//      SALOME::GenericObj_var genObj = SALOME::GenericObj::_narrow( theIOR );
-//      if ( !genObj->_is_nil() )
-//        genObj->UnRegister();
+      // UnRegister() !!! --> random problems when meshing in parallel (yacs foreach) in
+      // distributed python scripts, because simultaneously created meshes are
+      // published into the same SO; as a result the mesh published first dies
+      SALOME::GenericObj_var genObj = SALOME::GenericObj::_narrow( theIOR );
+      if ( !genObj->_is_nil() )
+        genObj->UnRegister();
     }
   }
 
@@ -598,7 +600,7 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
     else
       aTag++;
 
-    aMeshSO = publish ( theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" );
+    aMeshSO = publish( theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" );
     if ( aMeshSO->_is_nil() )
       return aMeshSO._retn();
   }
@@ -891,8 +893,10 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh )
     SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN" );
   else if ( mesh_i->IsComputedOK() )
     SetPixMap( so, "ICON_SMESH_TREE_MESH" );
-  else
+  else if ( mesh_i->HasShapeToMesh() )
     SetPixMap( so, "ICON_SMESH_TREE_MESH_PARTIAL" );
+  else
+    SetPixMap( so, "ICON_SMESH_TREE_MESH_IMPORTED" );
 
   // set icons of sub-objects
   SALOMEDS::Study_var         study = getStudyServant();
@@ -1399,3 +1403,14 @@ int StudyContext::getOldId( const int newId )
   }
   return 0;
 }
+
+//=======================================================================
+//function : Clear
+//purpose  : clear data
+//=======================================================================
+
+void StudyContext::Clear()
+{
+  mapIdToIOR.Clear();
+  mapIdToId.Clear();
+}