From: srn Date: Thu, 14 Dec 2006 10:42:42 +0000 (+0000) Subject: In StudyManager removed Alliances code. In Sequences added check of Index correctness X-Git-Tag: SALOMEDS_UnitTests_1_2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=85251cedaa05bca40498d9006f8e9fb4632d5bf3;p=modules%2Fkernel.git In StudyManager removed Alliances code. In Sequences added check of Index correctness --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx index 459b8b26e..8519394a9 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx @@ -133,6 +133,9 @@ void SALOMEDSImpl_AttributeSequenceOfInteger::ChangeValue(const Standard_Integer { CheckLocked(); Backup(); + + if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range"); + myValue->SetValue(Index, Value); SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved @@ -151,6 +154,9 @@ void SALOMEDSImpl_AttributeSequenceOfInteger::Remove(const Standard_Integer Inde { CheckLocked(); Backup(); + + if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range"); + myValue->Remove(Index); SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved @@ -162,6 +168,8 @@ Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Length() } Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Value(const Standard_Integer Index) { + if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range"); + return myValue->Value(Index); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx index 1cad917f6..3d78ec633 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx @@ -132,6 +132,9 @@ void SALOMEDSImpl_AttributeSequenceOfReal::ChangeValue(const Standard_Integer In { CheckLocked(); Backup(); + + if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range"); + myValue->SetValue(Index, Value); SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved @@ -150,6 +153,9 @@ void SALOMEDSImpl_AttributeSequenceOfReal::Remove(const Standard_Integer Index) { CheckLocked(); Backup(); + + if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range"); + myValue->Remove(Index); SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved @@ -162,6 +168,7 @@ Standard_Integer SALOMEDSImpl_AttributeSequenceOfReal::Length() Standard_Real SALOMEDSImpl_AttributeSequenceOfReal::Value(const Standard_Integer Index) { + if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range"); return myValue->Value(Index); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index 0cde58ca0..dd91556cd 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -56,9 +56,6 @@ IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyManager, MMgt_TShared ) IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyManager, MMgt_TShared ) #define USE_CASE_LABEL_ID "0:2" -#define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2" -#define AUTO_SAVE_TAG "0:8" -#define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200 static void SaveAttributes(Handle(SALOMEDSImpl_SObject) SO, HDFgroup *hdf_group_sobject); static void ReadAttributes(const Handle(SALOMEDSImpl_Study)&, const Handle(SALOMEDSImpl_SObject)&, HDFdataset* ); @@ -558,11 +555,8 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator(); - //SRN: Added 17 Nov, 2003 - Handle(SALOMEDSImpl_SObject) anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG); - //SRN: End for (; itcomponent.More(); itcomponent.Next()) - { + { Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value(); TCollection_AsciiString scoid = sco->GetID(); @@ -570,46 +564,6 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, hdf_sco_group->CreateOnDisk(); TCollection_AsciiString componentDataType = sco->ComponentDataType(); - - //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save - if(!anAutoSaveSO.IsNull() && SB->IsGUID(sco, AUTO_SAVE_GUID)) { - - Handle(SALOMEDSImpl_AttributeTableOfString) aTable; - if(anAutoSaveSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTableOfString::GetID(), aTable)) { - Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0; - if(nbRows > 0 && aTable->GetNbColumns() > 1) { - - Handle(TColStd_HSequenceOfExtendedString) aRow; - for(k=1; k<=nbRows; k++) { - aRow = aTable->GetRowData(k); - if (aRow->Value(1) == componentDataType) { - TCollection_AsciiString anEntry = TCollection_AsciiString(aRow->Value(2)); - Handle(SALOMEDSImpl_SObject) aCompSpecificSO = aStudy->FindObjectID(anEntry); - if(!aCompSpecificSO.IsNull()) { - Handle(SALOMEDSImpl_AttributeInteger) anInteger; - if(aCompSpecificSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anInteger)) { - anInteger->SetValue(-1); - while(anInteger->Value() < 0) { -#ifndef WNT - sleep(2); -#else - Sleep(2); -#endif - if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) - break; - } - } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger")) - } // if(!CORBA::is_nil(aCompSpecificSO)) - } // if (strcmp(aRow[0], componentDataType) == 0) - } // for - - } // if(nbRows > 0 && aTable->GetNbColumns() > 1) - - } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString") - - } // if(SB->IsGUID(AUTO_SAVE_GUID) - - //SRN: End TCollection_AsciiString IOREngine; if (sco->ComponentIOR(IOREngine)) {