Salome HOME
PAL16774 (Crash after display of many groups)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.cxx
index cc8506198ad3a1e4eac1ead40fff0aa06d885293..1dd9b63804ee3c161020178a942dc7dfc69c8a83 100644 (file)
@@ -331,7 +331,7 @@ namespace SMESH {
       CASE2TEXT( COMPERR_BAD_INPUT_MESH);
       CASE2TEXT( COMPERR_STD_EXCEPTION );
       CASE2TEXT( COMPERR_OCC_EXCEPTION );
-      CASE2TEXT( COMPERR_SLM_EXCEPTION );
+    case SMESH::COMPERR_SLM_EXCEPTION: break; // avoid double "Salome exception"
       CASE2TEXT( COMPERR_EXCEPTION     );
       CASE2TEXT( COMPERR_MEMORY_PB     );
       CASE2TEXT( COMPERR_BAD_SHAPE     );
@@ -427,7 +427,7 @@ namespace SMESH {
   }
   // -----------------------------------------------------------------------
   /*!
-   * \brief Return text describing a subshape
+   * \brief Return a list of selected rows
    */
   bool getSelectedRows(QTable* table, list< int > & rows)
   {
@@ -440,6 +440,9 @@ namespace SMESH {
       for ( int row = selected.topRow(); row <= selected.bottomRow(); ++row )
         rows.push_back( row );
     }
+    if (rows.empty() && table->currentRow() > -1 )
+      rows.push_back( table->currentRow() );
+
     return !rows.empty();
   }
 
@@ -762,6 +765,7 @@ SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
   connect(myDlg->myShowBtn,    SIGNAL (clicked()), SLOT(onPreviewShape()));
   connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
   connect(table(),SIGNAL(selectionChanged()), SLOT(currentCellChanged()));
+  connect(table(),SIGNAL(currentChanged(int,int)), SLOT(currentCellChanged()));
 }
 
 //=======================================================================
@@ -781,7 +785,6 @@ void SMESHGUI_ComputeOp::startOperation()
   // COMPUTE MESH
 
   bool computeFailed = true, memoryLack = false;
-  int nbNodes = 0, nbEdges = 0, nbFaces = 0, nbVolums = 0;
 
   LightApp_SelectionMgr *Sel = selectionMgr();
   SALOME_ListIO selected; Sel->selectedObjects( selected );
@@ -803,7 +806,9 @@ void SMESHGUI_ComputeOp::startOperation()
     MemoryReserve aMemoryReserve;
     _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
     myMainShape = aMesh->GetShapeToMesh();
-    if ( !myMainShape->_is_nil() && aMeshSObj )
+    if ( ((!myMainShape->_is_nil() && aMesh->HasShapeToMesh()) ||
+          (myMainShape->_is_nil() && !aMesh->HasShapeToMesh()))
+         && aMeshSObj )
     {
       myDlg->myMeshName->setText( aMeshSObj->GetName() );
       SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
@@ -841,7 +846,7 @@ void SMESHGUI_ComputeOp::startOperation()
         //             return;
         //           }
         // check if there are memory problems
-        for ( int i = 0; i < anErrors->length() && !memoryLack; ++i )
+        for ( int i = 0; (i < anErrors->length()) && !memoryLack; ++i )
           memoryLack = ( anErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
       }
       catch(const SALOME::SALOME_Exception & S_ex){
@@ -852,7 +857,6 @@ void SMESHGUI_ComputeOp::startOperation()
       {
         SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0);
         update( UF_ObjBrowser | UF_Model );
-        Sel->setSelectedObjects( selected );
 
         // SHOW MESH
         // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
@@ -860,9 +864,9 @@ void SMESHGUI_ComputeOp::startOperation()
         {
           try {
 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
-          OCC_CATCH_SIGNALS;
+            OCC_CATCH_SIGNALS;
 #endif
-            SMESH::UpdateView(eDisplay, IObject->getEntry());
+            SMESH::Update(IObject, true);
           }
           catch (...) {
 #ifdef _DEBUG_
@@ -876,6 +880,7 @@ void SMESHGUI_ComputeOp::startOperation()
             }
           }
         }
+        Sel->setSelectedObjects( selected );
       }
     }
   }
@@ -916,10 +921,20 @@ void SMESHGUI_ComputeOp::startOperation()
     myDlg->myBriefInfo->show();
     myDlg->myFullInfo->hide();
     myDlg->myErrorGroup->show();
-
+    
+    bool hasShape = aMesh->HasShapeToMesh();
+    if ( !hasShape )
+    {
+      myDlg->myPublishBtn->hide();
+      myDlg->myShowBtn->hide();
+    }
+    else
+    {
+      myDlg->myPublishBtn->show();
+      myDlg->myShowBtn->show();
+    }
     // fill table of errors
     tbl->setNumRows( anErrors->length() );
-    bool hasShape = aMesh->HasShapeToMesh();
     if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
     else             tbl->showColumn( COL_SHAPE );
     tbl->setColumnWidth( COL_ERROR, 200 );