Salome HOME
PAL16774,PAL16631(SALOME crash after a mesh computation that failed because of lack...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 89ce6fe7a9880b49a2f379d8650046e5c2b9fae2..1d9632e8c608b71c44b6ded14288fc0a9b49f815 100644 (file)
@@ -308,7 +308,7 @@ using namespace std;
              there must be check on others mesh elements not equal triangles
            */
            if (aMesh->NbTriangles() < 1) {
-              int aRet = SUIT_MessageBox::warn1
+              SUIT_MessageBox::warn1
                 (SMESHGUI::desktop(),
                  QObject::tr("SMESH_WRN_WARNING"),
                  QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
@@ -1290,22 +1290,27 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 
       extractContainers( sel_objects, to_process );
 
-      if (vtkwnd) {
-       SALOME_ListIteratorOfListIO It( to_process );
-       for (; It.More(); It.Next()) {
-         Handle(SALOME_InteractiveObject) IOS = It.Value();
-         if (IOS->hasEntry()) {
-            SMESH::UpdateView(anAction, IOS->getEntry());
-            if (anAction == SMESH::eDisplayOnly)
-              anAction = SMESH::eDisplay;
-         }
-       }
-      }
+      try {
+        if (vtkwnd) {
+          SALOME_ListIteratorOfListIO It( to_process );
+          for (; It.More(); It.Next()) {
+            Handle(SALOME_InteractiveObject) IOS = It.Value();
+            if (IOS->hasEntry()) {
+              SMESH::UpdateView(anAction, IOS->getEntry());
+              if (anAction == SMESH::eDisplayOnly)
+                anAction = SMESH::eDisplay;
+            }
+          }
+        }
 
-      // PAL13338 + PAL15161 -->
-      if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) /*&& !automaticUpdate()*/ )
-       SMESH::UpdateView();
-      // PAL13338 + PAL15161 <--
+        // PAL13338 + PAL15161 -->
+        if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
+          SMESH::UpdateView();
+        // PAL13338 + PAL15161 <--
+      }
+      catch (...) { // PAL16774 (Crash after display of many groups)
+        SMESH::OnVisuException();
+      }
 
       if (anAction == SMESH::eErase) {
        SALOME_ListIO l1;
@@ -1364,82 +1369,6 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       if (checkLock(aStudy)) break;
 
       startOperation( 701 );
-//       LightApp_SelectionMgr *Sel = selectionMgr();
-//       SALOME_ListIO selected; Sel->selectedObjects( selected );
-
-//       int nbSel = selected.Extent();
-//       if (nbSel != 1) {
-//         SUIT_MessageBox::warn1(desktop(),
-//                                tr("SMESH_WRN_WARNING"),
-//                                tr("SMESH_WRN_NO_AVAILABLE_DATA"),
-//                                tr("SMESH_BUT_OK"));
-//         break;
-//       }
-
-//       SMESH::SMESH_Mesh_var aMesh;
-//       SMESH::SMESH_subMesh_var aSubMesh;
-//       Handle(SALOME_InteractiveObject) IObject = selected.First();
-//       if (IObject->hasEntry()) {
-//         _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
-//         GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
-//         if ( aShapeObject->_is_nil() ) {
-//           // imported mesh
-//           break;
-//         }
-//         if ( aMeshSObj ) {
-//           aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
-//           aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
-//           if ( !aSubMesh->_is_nil() )
-//             aMesh = aSubMesh->GetFather();
-
-//           if (!aMesh->_is_nil()) {
-//             SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
-//             if ( errors->length() > 0 ) {
-//               SUIT_MessageBox::warn1(desktop(),
-//                                      tr("SMESH_WRN_WARNING"),
-//                                      SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
-//                                      tr("SMESH_BUT_OK"));
-//               break;
-//             }
-
-//             try {
-//               if (GetSMESHGen()->Compute(aMesh, aShapeObject))
-//                 SMESH::ModifiedMesh(aMeshSObj, true);
-//               else
-//                 SUIT_MessageBox::warn1(desktop(),
-//                                        tr("SMESH_WRN_WARNING"),
-//                                        tr("SMESH_WRN_COMPUTE_FAILED"),
-//                                        tr("SMESH_BUT_OK"));
-//             }
-//             catch(const SALOME::SALOME_Exception & S_ex){
-//               SalomeApp_Tools::QtCatchCorbaException(S_ex);
-//             }
-
-//             updateObjBrowser();
-
-//             if (automaticUpdate()) {
-//               SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
-//               if (aVTKView) {
-//                 CORBA::Long anId = aStudy->StudyId();
-//                 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
-//                 if (aVisualObj) {
-//                   aVisualObj->Update();
-//                   SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
-//                   if (!anActor) {
-//                     anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
-//                     if (anActor) {
-//                       SMESH::DisplayActor(aVTKView, anActor); //apo
-//                       SMESH::FitAll();
-//                     }
-//                   }
-//                   SMESH::RepaintCurrentView();
-//                   Sel->setSelectedObjects( selected );
-//                 }
-//               }
-//             }
-//           }
-//         }
-//       }
     }
     break;
 
@@ -1857,17 +1786,18 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       int nbSel = selected.Extent();
 
       if (nbSel == 1) {
-       SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
+        Handle(SALOME_InteractiveObject) anIObject = selected.First();
+       SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
 
         /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
         /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects                   */
         /* Warning : however by internal mechanism all subMeshes icons are changed !                     */
-        if ( !Hyp->_is_nil() )
+        if ( !aHypothesis->_is_nil() )
         {
-          char* sName = Hyp->GetName();
-          SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
+          CORBA::String_var aHypType = aHypothesis->GetName();
+          SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
           if (aCreator)
-            aCreator->edit( Hyp.in(), desktop() );
+            aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
           else
           {
             // report error
@@ -3097,7 +3027,7 @@ void SMESHGUI::createPreferences()
 
   int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
   addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
-  int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
+  addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
 
   int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
   int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );