From: prascle Date: Fri, 12 Apr 2013 15:28:08 +0000 (+0000) Subject: PR: dump correction when sudies from older versions are loaded X-Git-Tag: V7_2_0~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b8e8a40b705e60fa08cf21942a70d30604cbd2f0;p=modules%2Fgeom.git PR: dump correction when sudies from older versions are loaded --- diff --git a/src/GEOM_I/GEOM_DumpPython.cc b/src/GEOM_I/GEOM_DumpPython.cc index 54d374521..010a24842 100644 --- a/src/GEOM_I/GEOM_DumpPython.cc +++ b/src/GEOM_I/GEOM_DumpPython.cc @@ -55,6 +55,29 @@ void RemoveTabulation( TCollection_AsciiString& theScript ) theScript = aString.c_str(); } +//======================================================================= +//function : ConvertV6toV7 +//purpose : dump elements are stored when study is saved, +// and kept when study is reloaded. +// When a study from an older version is loaded, +// the dump must be post processed in case of syntax modification. +// In V7.2, geompy.GEOM --> GEOM +//======================================================================= +void ConvertV6toV7( TCollection_AsciiString& theScript ) +{ + std::string aString( theScript.ToCString() ); + std::string::size_type aPos = 0; + while( aPos < aString.length() ) + { + aPos = aString.find( "geompy.GEOM", aPos ); + if( aPos == std::string::npos ) + break; + aString.replace( aPos, 11, "GEOM" ); + aPos++; + } + theScript = aString.c_str(); +} + //======================================================================= //function : DumpPython //purpose : @@ -177,6 +200,8 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy, if( !isMultiFile ) // remove unnecessary tabulation RemoveTabulation( aScript ); + ConvertV6toV7( aScript ); //convert scripts related to studies saved in SALOME V6 and older + int aLen = aScript.Length(); unsigned char* aBuffer = new unsigned char[aLen+1]; strcpy((char*)aBuffer, aScript.ToCString());