From fd6f0fdf57aa43878b3c54f69a639192d8e006d8 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 30 Apr 2014 18:33:20 +0400 Subject: [PATCH] Regression bugs_00/A3 More protection from access to a closed study --- src/SMESH_I/SMESH_Gen_i.cxx | 16 ++++++++++++---- src/SMESH_I/SMESH_Gen_i_1.cxx | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index c9243ad87..a42b136d8 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -658,6 +658,8 @@ void SMESH_Gen_i::setCurrentStudy( SALOMEDS::Study_ptr theStudy, SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy() { if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetCurrentStudy: study Id = " << GetCurrentStudyID() ); + if ( GetCurrentStudyID() < 0 ) + return SALOMEDS::Study::_nil(); return SALOMEDS::Study::_duplicate( myCurrentStudy ); } @@ -1052,13 +1054,18 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa aPythonDump << "(["; if (theStatus == SMESH::DRS_OK) { - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - aStudyBuilder->NewCommand(); // There is a transaction + SALOMEDS::StudyBuilder_var aStudyBuilder; + if ( GetCurrentStudyID() > -1 ) + { + aStudyBuilder = myCurrentStudy->NewBuilder(); + aStudyBuilder->NewCommand(); // There is a transaction + } aResult->length( aNames.size() ); int i = 0; // Iterate through all meshes and create mesh objects - for ( list::iterator it = aNames.begin(); it != aNames.end(); it++ ) { + for ( list::iterator it = aNames.begin(); it != aNames.end(); it++ ) + { // Python Dump if (i > 0) aPythonDump << ", "; @@ -1091,7 +1098,8 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa aResult[i++] = SMESH::SMESH_Mesh::_duplicate( mesh ); meshServant->GetImpl().GetMeshDS()->Modified(); } - aStudyBuilder->CommitCommand(); + if ( !aStudyBuilder->_is_nil() ) + aStudyBuilder->CommitCommand(); } // Update Python script diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index f155ae93d..6890bcf08 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -160,7 +160,7 @@ long SMESH_Gen_i::GetBallElementsGroupsTag() bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) { if(MYDEBUG) MESSAGE("CanPublishInStudy - "<