From 35012b0a3d7a04ff4af9f1622340a814b3f1300b Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 1 Aug 2018 18:41:11 +0300 Subject: [PATCH] Fix mixed Python dump of a new and a closed study --- src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 2 +- src/SMESH_I/SMESH_Gen_i.cxx | 3 +++ src/SMESH_I/SMESH_PythonDump.cxx | 35 +++++++++++++++--------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index b0cce7c37..36534f31a 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1120,7 +1120,7 @@ bool SMESHGUI_GroupDlg::onApply() myGroupOnFilter = myMesh->CreateGroupFromFilter(aType, myName->text().toUtf8(), - myFilter); + myFilter); resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter ); isCreation = true; } diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 5724095a8..e6ebe05e9 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -4971,6 +4971,9 @@ void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent ) // remove the tmp files meshes are loaded from SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD( theComponent ); + // Clean trace of API methods calls + CleanPythonTrace(); + return; } diff --git a/src/SMESH_I/SMESH_PythonDump.cxx b/src/SMESH_I/SMESH_PythonDump.cxx index e4dfed32c..7ffedf1d4 100644 --- a/src/SMESH_I/SMESH_PythonDump.cxx +++ b/src/SMESH_I/SMESH_PythonDump.cxx @@ -678,33 +678,33 @@ namespace SMESH cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl; #endif } -} //======================================================================= //function : RemoveTabulation //purpose : //======================================================================= -void RemoveTabulation( TCollection_AsciiString& theScript ) -{ - std::string aString( theScript.ToCString() ); - std::string::size_type aPos = 0; - while( aPos < aString.length() ) + void RemoveTabulation( TCollection_AsciiString& theScript ) { - aPos = aString.find( "\n\t", aPos ); - if( aPos == std::string::npos ) - break; - aString.replace( aPos, 2, "\n" ); - aPos++; + std::string aString( theScript.ToCString() ); + std::string::size_type aPos = 0; + while( aPos < aString.length() ) + { + aPos = aString.find( "\n\t", aPos ); + if( aPos == std::string::npos ) + break; + aString.replace( aPos, 2, "\n" ); + aPos++; + } + theScript = aString.c_str(); } - theScript = aString.c_str(); } //======================================================================= //function : DumpPython //purpose : //======================================================================= -Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished, - CORBA::Boolean isMultiFile, +Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished, + CORBA::Boolean isMultiFile, CORBA::Boolean& isValidScript) { SALOMEDS::Study_var aStudy = getStudyServant(); @@ -995,10 +995,9 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl std::list< TCollection_AsciiString > lines; // lines of a script std::list< TCollection_AsciiString >::iterator linesIt; - if ( isPublished ) - lines.push_back( aSMESHGen + " = smeshBuilder.New()" ); - else - lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" ); + lines.push_back( aSMESHGen + " = smeshBuilder.New()" ); + if ( !isPublished ) + lines.push_back( aSMESHGen + ".SetEnablePublish( False )" ); lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" ); lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );