Salome HOME
Start "Create group" with selected GEOM object occurs crash
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_VTKUtils.cxx
index b918db58dd3b97815a6eda2571f020e04a26a026..924450bb9039b1bf5c9ab0af174fea58eaeab7a9 100644 (file)
@@ -145,16 +145,8 @@ namespace SMESH{
   SVTK_ViewWindow*
   GetViewWindow(const SalomeApp_Module* theModule)
   {
-    if(SalomeApp_Application* anApp = theModule->getApp()){
-      if(SUIT_ViewManager* aViewManager = anApp->activeViewManager()){
-       if(aViewManager->getType() == SVTK_Viewer::Type()){
-         if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
-           return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
-         }
-       }
-      }
-    }
-    return NULL;
+    if(SalomeApp_Application* anApp = theModule->getApp())
+      return dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
   }
 
   SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager* theMgr,
@@ -416,13 +408,32 @@ namespace SMESH{
   }
 
 
-  void UpdateSelectionProp() {
-    SUIT_Study* aStudy = GetActiveStudy();
-    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
+  void UpdateSelectionProp( SMESHGUI* theModule ) {
+    if( !theModule )
+      return;
+
+    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
+    if( !app )
+    {
+      MESSAGE( "UpdateSelectionProp: Application is null" );
+      return;
+    }
+
     SUIT_ViewManager* vm = app->activeViewManager();
+    if( !vm )
+    {
+      MESSAGE( "UpdateSelectionProp: View manager is null" );
+      return;
+    }
+
     QPtrVector<SUIT_ViewWindow> views = vm->getViews();
 
-    SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
+    SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
+    if( !mgr )
+    {
+      MESSAGE( "UpdateSelectionProp: Resource manager is null" );
+      return;
+    }
 
     QColor aHiColor = mgr->colorValue( "SMESH", "SettingsSelectColor", Qt::white ),
            aSelColor = mgr->colorValue( "SMESH", "SettingsItemSelectColor", Qt::yellow ),