Salome HOME
Fix bug 17577: Help in 4x: Page is not displayed.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 0db20e7daffce5e127f5e01e139807d91fc58c87..ba766e20a9565c186252eb55877e1e2fd6ac63b3 100644 (file)
 #include "SALOMEDSClient_StudyBuilder.hxx"
 #include "SALOMEDSClient_SComponent.hxx"
 
+#include <Standard_ErrorHandler.hxx>
+
 using namespace std;
 
 //namespace{
@@ -539,7 +541,14 @@ using namespace std;
 
       _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
       if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str()))
-       anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
+      {
+       if( aGroupObject->GetType() == SMESH::NODE )
+         anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
+       else if( aGroupObject->GetType() == SMESH::EDGE )
+         anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
+       else
+         anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
+      }
     }
 
     SMESH::RepaintCurrentView();
@@ -1348,7 +1357,18 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 214:                                    // UPDATE
     {
       if(checkLock(aStudy)) break;
-      SMESH::UpdateView();
+      try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+        OCC_CATCH_SIGNALS;
+#endif
+        SMESH::UpdateView();
+      }
+      catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
+        SMESH::OnVisuException();
+      }
+      catch (...) { // PAL16774 (Crash after display of many groups)
+        SMESH::OnVisuException();
+      }
 
       SALOME_ListIO l;
       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
@@ -1379,12 +1399,16 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       extractContainers( sel_objects, to_process );
 
       try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+        OCC_CATCH_SIGNALS;
+#endif
         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 (!SMESH::UpdateView(anAction, IOS->getEntry()))
+                break; // PAL16774 (Crash after display of many groups)
               if (anAction == SMESH::eDisplayOnly)
                 anAction = SMESH::eDisplay;
             }
@@ -3030,6 +3054,12 @@ bool SMESHGUI::deactivateModule( SUIT_Study* study )
   return SalomeApp_Module::deactivateModule( study );
 }
 
+void SMESHGUI::studyClosed( SUIT_Study* s )
+{
+  SMESH::RemoveVisuData( s->id() );
+  SalomeApp_Module::studyClosed( s );
+}
+
 void SMESHGUI::OnGUIEvent()
 {
   const QObject* obj = sender();