From 7f1cf8210240b6fb99c8c58558d03e608e6aa78b Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 24 Mar 2006 09:09:25 +0000 Subject: [PATCH] Fix for Bug IPAL11942 "AttributeError" is raised by "CreatePrsForMed()". --- src/VISU_I/VISU_Result_i.cc | 118 +++++++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 30 deletions(-) diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 360579fc..e75c21f1 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -213,6 +213,9 @@ namespace VISU aStudyBuilder->Addreference(aNewObj,aRefSObj); } + + //--------------------------------------------------------------- + inline std::string CreateAttributes(_PTR(Study) theStudyDocument, const string& theFatherEntry, @@ -251,6 +254,9 @@ namespace VISU return aNewObj->GetID(); } + + //--------------------------------------------------------------- + inline void UpdateAttributes(_PTR(Study) theStudyDocument, const string& theEntry, @@ -282,6 +288,20 @@ namespace VISU } + //--------------------------------------------------------------- + inline + void + RemoveSObject(_PTR(Study) theStudyDocument, + const string& theEntry) + { + TLock aLock(myMutex); + + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry); + aStudyBuilder->RemoveObject(aSObject); + } + + //--------------------------------------------------------------- struct TResultManager { @@ -364,6 +384,7 @@ namespace VISU VISU_Convertor* theInput, CORBA::Boolean* theIsDone, std::string theResultEntry, + CORBA::Boolean theIsAtOnce, CORBA::Boolean theIsBuildGroups, CORBA::Boolean theIsBuildFields, _PTR(Study) theStudy) @@ -411,24 +432,26 @@ namespace VISU aComment.latin1(), true); - if(theIsBuildGroups){ - aMesh->myGroupsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); - } - - if(theIsBuildFields){ - aMesh->myFieldsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); + if(!theIsAtOnce){ + if(theIsBuildGroups){ + aMesh->myGroupsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + "", + "", + "", + true); + } + + if(theIsBuildFields){ + aMesh->myFieldsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + "", + "", + "", + true); + } } //Import entities @@ -479,6 +502,7 @@ namespace VISU VISU_Convertor* theInput, CORBA::Boolean* theIsDone, CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, _PTR(Study) theStudy) { if(!theIsBuild || *theIsDone) @@ -533,11 +557,22 @@ namespace VISU if(!aGroupMap.empty()){ aComment.sprintf("myComment=GROUPS;myMeshName=%s", aMeshName.c_str()); - UpdateAttributes(theStudy, - aMesh->myGroupsEntry, - "", - "Groups", - aComment.latin1()); + + if(theIsAtOnce) + aMesh->myGroupsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + "", + "Groups", + aComment.latin1(), + true); + else + UpdateAttributes(theStudy, + aMesh->myGroupsEntry, + "", + "Groups", + aComment.latin1()); + TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ const string& aGroupName = aGroupMapIter->first; @@ -560,7 +595,9 @@ namespace VISU aFamily->myEntry); } } - } + }else if(!theIsAtOnce) + RemoveSObject(theStudy, + aMesh->myGroupsEntry); } ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); @@ -573,6 +610,7 @@ namespace VISU VISU_Convertor* theInput, CORBA::Boolean* theIsDone, CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, _PTR(Study) theStudy) { if(!theIsBuild || *theIsDone) @@ -600,7 +638,6 @@ namespace VISU //Import fields bool anIsFieldsEntryUpdated = false; - TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ const TEntity& anEntity = aMeshOnEntityMapIter->first; @@ -611,11 +648,22 @@ namespace VISU if(!anIsFieldsEntryUpdated){ aComment.sprintf("myComment=FIELDS;myMeshName=%s", aMeshName.c_str()); - UpdateAttributes(theStudy, - aMesh->myFieldsEntry, - "", - "Fields", - aComment.latin1()); + + if(theIsAtOnce) + aMesh->myFieldsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + "", + "Fields", + aComment.latin1(), + true); + else + UpdateAttributes(theStudy, + aMesh->myFieldsEntry, + "", + "Fields", + aComment.latin1()); + anIsFieldsEntryUpdated = true; } const string& aFieldName = aFieldMapIter->first; @@ -661,6 +709,10 @@ namespace VISU } } } + + if(!anIsFieldsEntryUpdated && !theIsAtOnce) + RemoveSObject(theStudy, + aMesh->myFieldsEntry); } ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); @@ -704,6 +756,7 @@ namespace VISU theInput, theIsFieldsDone, theIsBuildFields, + false, theStudy); BuildMinMax(theResult, @@ -766,6 +819,7 @@ namespace VISU theBuildArgs.myInput, theBuildArgs.myIsEntitiesDone, theBuildArgs.myResultEntry, + false, theBuildArgs.myIsBuildGroups, theBuildArgs.myIsBuildFields, theBuildArgs.myStudy); @@ -775,6 +829,7 @@ namespace VISU theBuildArgs.myInput, theBuildArgs.myIsGroupsDone, theBuildArgs.myIsBuildGroups, + false, theBuildArgs.myStudy)); } { @@ -1044,6 +1099,7 @@ VISU::Result_i myInput, &myIsEntitiesDone, aResultEntry, + theIsAtOnce, myIsBuildGroups, myIsBuildFields, myStudy); @@ -1052,12 +1108,14 @@ VISU::Result_i myInput, &myIsGroupsDone, myIsBuildGroups, + theIsAtOnce, myStudy); BuildFields(this, myInput, &myIsFieldsDone, myIsBuildFields, + theIsAtOnce, myStudy); BuildMinMax(this, -- 2.39.2