Salome HOME
bos #24257 [CEA] Fatal error when creating a submesh if the mesh is on a sub-shape
[modules/smesh.git] / src / MEDWrapper / MED_Factory.cxx
index 278838a0c3b89e9933b22496820f56b34e6ac007..e8c145f8ca66f7bdae91658de313f04e1b855498 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -196,13 +196,13 @@ namespace MED
     }
     med_int wantedMajor = MED_MAJOR_NUM;
     med_int wantedMinor = MED_MINOR_NUM;
-    if (isCreated)
+    // when non managed version of file is requested : ignore it and take the latest version
+    std::vector<int> versionsOK(GetMEDVersionsAppendCompatible());
+    bool isVersionRequestedOK(std::find(versionsOK.begin(),versionsOK.end(),theVersion)!=versionsOK.end());
+    if (isCreated && isVersionRequestedOK)
     {
-      if (theVersion > 0)
-      {
-        wantedMajor = theVersion/10;
-        wantedMinor = theVersion%10;
-      }
+      wantedMajor = theVersion/10;
+      wantedMinor = theVersion%10;
     }
     return new MED::TWrapper(fileName, true, wantedMajor, wantedMinor);
   }