Salome HOME
Merge 'abn/V8_1_fix' branch into V8_1_BR.
[modules/med.git] / src / MEDCalc / cmp / MEDPresentationManager_i.cxx
index 63ffed2af6aa972488d95ffa52c172946317043d..6317ed3e44952dbcb99300aaa5add7b6fb89ee72 100644 (file)
@@ -295,7 +295,17 @@ MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID)
   }
   MEDPresentation* presentation = (*citr).second;
 
-  presentation->activateView();
+  if (!presentation->activateView())
+    {
+      // The view has been recreated - transfer all presentations that were in the deleted view to this new one
+      int viewId = presentation->getPyViewID();
+      std::map<MEDPresentation::TypeID, MEDPresentation*>::iterator citr = _presentations.begin();
+      for (; citr != _presentations.end(); ++citr)
+        {
+          if(citr->second->getPyViewID() == viewId)
+            citr->second->recreateViewSetup();
+        }
+    }
   _activeViewPythonId = presentation->getPyViewID();
   STDLOG("Activated view " << _activeViewPythonId);
   return true;
@@ -346,3 +356,13 @@ MEDPresentationManager_i::getAllPresentations()
     (*presList)[i] = it->first;
   return presList;
 }
+
+void
+MEDPresentationManager_i::cleanUp()
+{
+  _activeViewPythonId = -1;
+  std::map<MEDPresentation::TypeID, MEDPresentation*>::iterator it;
+  for (it = _presentations.begin(); it != _presentations.end(); ++it)
+    delete(it->second);
+  _presentations.clear();
+}