From fa7612374ad996fac6340e7478d47eb2db8bbc11 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 22 Apr 2011 14:44:29 +0000 Subject: [PATCH] Fix problem in DifferenceList() function: when group becomes empty, an invalid compound is created by error. --- src/GEOMImpl/GEOMImpl_IGroupOperations.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx index cf81ed23c..86ed5fbe7 100644 --- a/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx @@ -485,14 +485,20 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup, if (mapIDsToRemove.Extent() > 0) { Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent(); - Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength); - - for (j = 1; j <= aLength; j++) { - if (!mapIDsToRemove.Contains(aSeq->Value(j))) { - aNewSeq->SetValue(k, aSeq->Value(j)); - k++; + Handle(TColStd_HArray1OfInteger) aNewSeq; + if ( aLength - aRemLength > 0 ) { + aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength); + for (j = 1; j <= aLength; j++) { + if (!mapIDsToRemove.Contains(aSeq->Value(j))) { + aNewSeq->SetValue(k, aSeq->Value(j)); + k++; + } } } + else { + aNewSeq = new TColStd_HArray1OfInteger(1,1); + aNewSeq->SetValue(1, -1); + } aSSI.SetIndices(aNewSeq); -- 2.39.2