From e44923390d86a0ef13bc5e1f9a9b59240322c4ee Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 24 Jan 2014 11:44:33 +0000 Subject: [PATCH] Correction of bug found thanks to MEDReader. --- src/MEDLoader/MEDFileField.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 1df7f7114..0d5f1216e 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -4126,16 +4126,24 @@ void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector if(_nb_of_tuples_to_be_allocated>=0) { _nb_of_tuples_to_be_allocated=newLgth; + const DataArray *oldArr(getUndergroundDataArray()); + if(oldArr) + { + MEDCouplingAutoRefCountObjectPtr newArr(createNewEmptyDataArrayInstance()); + newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents()); + setArray(newArr); + _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy + } return ; } if(_nb_of_tuples_to_be_allocated==-1) return ; if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3) { - const DataArray *oldArr=getUndergroundDataArray(); + const DataArray *oldArr(getUndergroundDataArray()); if(!oldArr || !oldArr->isAllocated()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !"); - MEDCouplingAutoRefCountObjectPtr newArr=createNewEmptyDataArrayInstance(); + MEDCouplingAutoRefCountObjectPtr newArr(createNewEmptyDataArrayInstance()); newArr->alloc(newLgth,getNumberOfComponents()); if(oldArr) newArr->copyStringInfoFrom(*oldArr); -- 2.39.2