Salome HOME
Merge 'abn/V8_1_fix' branch into V8_1_BR.
[modules/med.git] / src / MEDCalc / cmp / MEDPresentationManager_i.cxx
index 9fd1a1e6ac0fa1857c81dac465cb54828a56686b..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;
@@ -324,12 +334,12 @@ MEDPresentationManager_i::getActiveViewPythonId()
 //  }
 //}
 
-char*
+char *
 MEDPresentationManager_i::getParavisDump(MEDPresentation::TypeID presentationID)
 {
   MEDPresentation* pres = _getPresentation(presentationID);
   if (pres) {
-    return (char*) pres->paravisDump().c_str();
+    return CORBA::string_dup(pres->paravisDump().c_str());
   }
   else
     throw KERNEL::createSalomeException("getParavisDump(): presentation not found!!");
@@ -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();
+}