From: san Date: Fri, 19 Jul 2013 16:03:13 +0000 (+0000) Subject: 22238: Study dump produced by SMESH refers to undefined variable names - merged from... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1779fc70bbece0d8b22573609166cff1fe6bfcb7;p=modules%2Fsmesh.git 22238: Study dump produced by SMESH refers to undefined variable names - merged from V6_7_BR --- diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 779339154..06caae30e 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -170,8 +170,16 @@ namespace { cmd->Clear(); return; } - // comment a command having not created args - for ( int iArg = cmd->GetNbArgs(); iArg; --iArg ) + // check if an Object was created in the script + _AString comment; + const _pyID& obj = cmd->GetObject(); + if ( !obj.IsEmpty() && cmd->IsStudyEntry( obj ) && !presentObjects.count( obj )) + { + comment = "not created Object"; + theGen->ObjectCreationRemoved( obj ); + } + // check if a command has not created args + for ( int iArg = cmd->GetNbArgs(); iArg && comment.IsEmpty(); --iArg ) { const _pyID& arg = cmd->GetArg( iArg ); if ( arg.IsEmpty() || arg.Value( 1 ) == '"' || arg.Value( 1 ) == '\'' ) @@ -181,34 +189,29 @@ namespace { for ( ; id != idList.end(); ++id ) if ( !theGen->IsGeomObject( *id ) && !presentObjects.count( *id )) { - cmd->Comment(); - cmd->GetString() += " ### " ; - cmd->GetString() += *id + " has not been yet created"; - for ( int i = 0; i < cmd->GetNbResultValues(); i++ ) { - _pyID objID = cmd->GetResultValue( i+1 ); - theGen->ObjectCreationRemoved( objID ); // objID.SetName( name ) is not needed - } - return; + comment += *id + " has not been yet created"; + break; } } - // comment a command having not created Object - const _pyID& obj = cmd->GetObject(); - if ( !obj.IsEmpty() && cmd->IsStudyEntry( obj ) && !presentObjects.count( obj )) - { - cmd->Comment(); - cmd->GetString() += " ### not created object" ; - for ( int i = 0; i < cmd->GetNbResultValues(); i++ ) { - _pyID objID = cmd->GetResultValue( i+1 ); - theGen->ObjectCreationRemoved( objID ); // objID.SetName( name ) is not needed - } + // treat result objects + const _pyID& result = cmd->GetResultValue(); + if ( !result.IsEmpty() && result.Value( 1 ) != '"' && result.Value( 1 ) != '\'' ) + { + list< _pyID > idList = cmd->GetStudyEntries( result ); + list< _pyID >::iterator id = idList.begin(); + for ( ; id != idList.end(); ++id ) + if ( comment.IsEmpty() ) + presentObjects.insert( *id ); + else + theGen->ObjectCreationRemoved( *id ); // objID.SetName( name ) is not needed + } + // comment the command + if ( !comment.IsEmpty() ) + { + cmd->Comment(); + cmd->GetString() += " ### "; + cmd->GetString() += comment; } - const _pyID& result = cmd->GetResultValue(); - if ( result.IsEmpty() || result.Value( 1 ) == '"' || result.Value( 1 ) == '\'' ) - return; - list< _pyID > idList = cmd->GetStudyEntries( result ); - list< _pyID >::iterator id = idList.begin(); - for ( ; id != idList.end(); ++id ) - presentObjects.insert( *id ); } //================================================================================ @@ -3002,6 +3005,7 @@ int _pyCommand::GetBegPos( int thePartIndex ) return EMPTY; if ( myBegPos.Length() < thePartIndex ) return UNKNOWN; + ASSERT( thePartIndex > 0 ); return myBegPos( thePartIndex ); } @@ -3017,6 +3021,7 @@ void _pyCommand::SetBegPos( int thePartIndex, int thePosition ) { while ( myBegPos.Length() < thePartIndex ) myBegPos.Append( UNKNOWN ); + ASSERT( thePartIndex > 0 ); myBegPos( thePartIndex ) = thePosition; } @@ -3544,7 +3549,7 @@ void _pyCommand::Comment() if ( i <= Length() ) { myString.Insert( i, "#" ); - for ( int iPart = 0; iPart < myBegPos.Length(); ++iPart ) + for ( int iPart = 1; iPart <= myBegPos.Length(); ++iPart ) { int begPos = GetBegPos( iPart ); if ( begPos != UNKNOWN ) diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index 734cc3108..b409ca968 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -934,7 +934,8 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl do { aName = aBaseName + (++objectCounter); } while (theObjectNames.IsBound(aName)); - seqRemoved.Append(aName); + if ( !aRemovedObjIDs.count( anEntry )) + seqRemoved.Append(aName); mapRemoved.Bind(anEntry, "1"); theObjectNames.Bind(anEntry, aName); } @@ -972,7 +973,6 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()"; } for (int ir = 1; ir <= seqRemoved.Length(); ir++) { - if ( aRemovedObjIDs.count( seqRemoved.Value(ir) )) continue; anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR("; anUpdatedScript += seqRemoved.Value(ir); // for object wrapped by class of smesh.py @@ -983,12 +983,8 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl } // Set object names - anUpdatedScript += "\n\t## set object names"; -// anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")"; -// anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())"; -// anUpdatedScript += "\n"; - TCollection_AsciiString aGUIName; + TCollection_AsciiString aGUIName, aSetNameScriptPart; Resource_DataMapOfAsciiStringAsciiString mapEntries; for (Standard_Integer i = 1; i <= aLen; i += 2) { @@ -1003,16 +999,17 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl aName = theObjectNames.Find(anEntry); aGUIName = theNames.Find(anEntry); mapEntries.Bind(anEntry, aName); - anUpdatedScript += helper + "\n\t" + aSMESHGen + ".SetName(" + aName; + aSetNameScriptPart += helper + "\n\t" + aSMESHGen + ".SetName(" + aName; if ( anEntry2AccessorMethod.IsBound( anEntry ) ) - anUpdatedScript += helper + "." + anEntry2AccessorMethod( anEntry ); - anUpdatedScript += helper + ", '" + aGUIName + "')"; + aSetNameScriptPart += helper + "." + anEntry2AccessorMethod( anEntry ); + aSetNameScriptPart += helper + ", '" + aGUIName + "')"; } } - - // Issue 0021249: removed (a similar block is dumped by SALOMEDSImpl_Study) - //anUpdatedScript += "\n\tif salome.sg.hasDesktop():"; - //anUpdatedScript += "\n\t\tsalome.sg.updateObjBrowser(0)"; + if ( !aSetNameScriptPart.IsEmpty() ) + { + anUpdatedScript += "\n\t## set object names"; + anUpdatedScript += aSetNameScriptPart; + } // ----------------------------------------------------------------- // store visual properties of displayed objects