From e5db9d8f50633792f4c5511f38797c2005424720 Mon Sep 17 00:00:00 2001 From: abv Date: Thu, 16 Jul 2015 00:34:02 +0300 Subject: [PATCH] 0026448: Method Prepend() of sequence breaks it if argument is empty sequence Check for empty input sequence added in methods Append() and Prepend() of TCollection and NCollection sequences. Test bugs fclasses bug26448 added --- src/NCollection/NCollection_BaseSequence.cxx | 4 ++++ src/QABugs/QABugs_19.cxx | 17 +++++++++++++++++ src/TCollection/TCollection_BaseSequence.cxx | 4 ++++ tests/bugs/fclasses/bug26448 | 10 ++++++++++ 4 files changed, 35 insertions(+) create mode 100644 tests/bugs/fclasses/bug26448 diff --git a/src/NCollection/NCollection_BaseSequence.cxx b/src/NCollection/NCollection_BaseSequence.cxx index fa39c9ae47..ed4fb9fc0b 100644 --- a/src/NCollection/NCollection_BaseSequence.cxx +++ b/src/NCollection/NCollection_BaseSequence.cxx @@ -68,6 +68,8 @@ void NCollection_BaseSequence::PAppend (NCollection_SeqNode * theItem) void NCollection_BaseSequence::PAppend(NCollection_BaseSequence& Other) { + if (Other.mySize == 0) + return; if (mySize == 0) { mySize = Other.mySize; myFirstItem = Other.myFirstItem; @@ -113,6 +115,8 @@ void NCollection_BaseSequence::PPrepend (NCollection_SeqNode * theItem) void NCollection_BaseSequence::PPrepend (NCollection_BaseSequence& Other) { + if (Other.mySize == 0) + return; if (mySize == 0) { mySize = Other.mySize; myFirstItem = Other.myFirstItem; diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 208c9c66ab..675efb13b4 100755 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -3866,6 +3866,22 @@ static Standard_Integer OCC24923( return 0; } +static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **) +{ + TColStd_SequenceOfReal aSeq1, aSeq2; + aSeq1.Append(11.); + aSeq1.Prepend (aSeq2); + theDI << "TCollection: 11 -> " << aSeq1.First() << "\n"; + + NCollection_Sequence nSeq1, nSeq2; + nSeq1.Append(11.); + nSeq1.Prepend (nSeq2); + theDI << "NCollection: 11 -> " << nSeq1.First() << "\n"; + + theDI << "OK"; + return 0; +} + void QABugs::Commands_19(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -3938,5 +3954,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group); theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group); theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group); + theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group); return; } diff --git a/src/TCollection/TCollection_BaseSequence.cxx b/src/TCollection/TCollection_BaseSequence.cxx index 3d84873687..b551829d0d 100644 --- a/src/TCollection/TCollection_BaseSequence.cxx +++ b/src/TCollection/TCollection_BaseSequence.cxx @@ -66,6 +66,8 @@ void TCollection_BaseSequence::PAppend(const Standard_Address newnode) // --------------------------------------------------- void TCollection_BaseSequence::PAppend(TCollection_BaseSequence& Other) { + if (Other.Size == 0) + return; if (Size == 0) { Size = Other.Size; FirstItem = Other.FirstItem; @@ -103,6 +105,8 @@ void TCollection_BaseSequence::PPrepend(const Standard_Address newnode) void TCollection_BaseSequence::PPrepend(TCollection_BaseSequence& Other) { + if (Other.Size == 0) + return; if (Size == 0) { Size = Other.Size; FirstItem = Other.FirstItem; diff --git a/tests/bugs/fclasses/bug26448 b/tests/bugs/fclasses/bug26448 new file mode 100644 index 0000000000..fe1f6635eb --- /dev/null +++ b/tests/bugs/fclasses/bug26448 @@ -0,0 +1,10 @@ +puts "============" +puts "OCC26448" +puts "============" +puts "" +####################################################################### +# Method Prepend() of sequence breaks it if argument is empty sequence +####################################################################### + +pload QAcommands +OCC26448 -- 2.39.5