From 4a5eefb909cb34f517437b9f3abfe18d7e2e7061 Mon Sep 17 00:00:00 2001 From: szy Date: Wed, 20 Dec 2017 12:20:29 +0300 Subject: [PATCH] 0029371: The problem of the attributes constructor call Default Guid is assigned in constructor. Add test case: tests\bugs\caf\bug29371. --- src/QABugs/QABugs_20.cxx | 180 ++++++++++++++++++++++- src/TDataStd/TDataStd_AsciiString.cxx | 2 +- src/TDataStd/TDataStd_BooleanArray.cxx | 6 +- src/TDataStd/TDataStd_BooleanList.cxx | 6 +- src/TDataStd/TDataStd_ByteArray.cxx | 3 +- src/TDataStd/TDataStd_ExtStringArray.cxx | 5 +- src/TDataStd/TDataStd_ExtStringList.cxx | 2 +- src/TDataStd/TDataStd_Integer.cxx | 2 +- src/TDataStd/TDataStd_IntegerArray.cxx | 2 +- src/TDataStd/TDataStd_IntegerList.cxx | 6 +- src/TDataStd/TDataStd_Name.cxx | 2 +- src/TDataStd/TDataStd_Real.cxx | 3 +- src/TDataStd/TDataStd_RealArray.cxx | 3 +- src/TDataStd/TDataStd_RealList.cxx | 6 +- src/TDataStd/TDataStd_ReferenceArray.cxx | 6 +- src/TDataStd/TDataStd_ReferenceList.cxx | 6 +- tests/bugs/caf/bug29371 | 8 + 17 files changed, 213 insertions(+), 35 deletions(-) create mode 100644 tests/bugs/caf/bug29371 diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index df972f2868..2f014583c4 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -2590,6 +2590,184 @@ static Standard_Integer OCC29289(Draw_Interpretor&, Standard_Integer , const cha return err; } +//=============================================================================================== +Standard_Boolean IsSameGuid (const Standard_GUID& aGuidNull, const Standard_GUID& aGuid2) +{ + Standard_Boolean isSame (Standard_False); + if(Standard_GUID::IsEqual(aGuidNull, aGuid2)) { + aGuid2.ShallowDump(cout); + isSame = Standard_True; + } else { + aGuid2.ShallowDump(cout); + cout < +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define QCOMPARE(val1, val2) \ + di << "Checking " #val1 " == " #val2 << \ + ((val1) == (val2) ? ": OK\n" : ": Error\n") + +static Standard_Integer OCC29371 (Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + if (n != 1) + { + std::cout << "Usage : " << a[0] << "\n"; + return 1; + } + + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + Handle(TDocStd_Document) aDoc; + anApp->NewDocument ("BinOcaf", aDoc); + TDF_Label aLab = aDoc->Main(); + Standard_GUID aNullGuid("00000000-0000-0000-0000-000000000000"); + Standard_Boolean IsNullGuid(Standard_False); + + try { + //1. Set TDataStd_AsciiString + Handle(TDataStd_AsciiString) aStrAtt = new TDataStd_AsciiString(); + aLab.AddAttribute(aStrAtt); + if(!aStrAtt.IsNull()) { + Standard_GUID aGuid = aStrAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //2. Set TDataStd_BooleanArray + Handle(TDataStd_BooleanArray) aBArAtt = new TDataStd_BooleanArray(); + aLab.AddAttribute(aBArAtt); + if(!aBArAtt.IsNull()) { + Standard_GUID aGuid = aBArAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //3. Set TDataStd_BooleanList + Handle(TDataStd_BooleanList) aBListAtt = new TDataStd_BooleanList(); + aLab.AddAttribute(aBListAtt); + if(!aBListAtt.IsNull()) { + Standard_GUID aGuid = aBListAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //4. Set TDataStd_ByteArray + Handle(TDataStd_ByteArray) aByteArAtt = new TDataStd_ByteArray(); + aLab.AddAttribute(aByteArAtt); + if(!aByteArAtt.IsNull()) { + Standard_GUID aGuid = aByteArAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //5. Set TDataStd_ExtStringArray + Handle(TDataStd_ExtStringArray) anExtStrArAtt = new TDataStd_ExtStringArray(); + aLab.AddAttribute(anExtStrArAtt); + if(!anExtStrArAtt.IsNull()) { + Standard_GUID aGuid = anExtStrArAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //6. Set TDataStd_ExtStringList + Handle(TDataStd_ExtStringList) anExtStrListAtt = new TDataStd_ExtStringList(); + aLab.AddAttribute(anExtStrListAtt); + if(!anExtStrListAtt.IsNull()) { + Standard_GUID aGuid = anExtStrListAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //7. Set TDataStd_Integer + Handle(TDataStd_Integer) anIntAtt = new TDataStd_Integer(); + aLab.AddAttribute(anIntAtt); + if(!anIntAtt.IsNull()) { + Standard_GUID aGuid = anIntAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //8. Set TDataStd_IntegerArray + Handle(TDataStd_IntegerArray) anIntArrAtt = new TDataStd_IntegerArray(); + aLab.AddAttribute(anIntArrAtt); + if(!anIntArrAtt.IsNull()) { + Standard_GUID aGuid = anIntArrAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //9. Set TDataStd_IntegerList + Handle(TDataStd_IntegerList) anIntListAtt = new TDataStd_IntegerList(); + aLab.AddAttribute(anIntListAtt); + if(!anIntListAtt.IsNull()) { + Standard_GUID aGuid = anIntListAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //10. Set TDataStd_Name + Handle(TDataStd_Name) aNameAtt = new TDataStd_Name(); + aLab.AddAttribute(aNameAtt); + if(!aNameAtt.IsNull()) { + Standard_GUID aGuid = aNameAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //11. Set TDataStd_Real + Handle(TDataStd_Real) aRealAtt = new TDataStd_Real(); + aLab.AddAttribute(aRealAtt); + if(!aRealAtt.IsNull()) { + Standard_GUID aGuid = aRealAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //12. Set TDataStd_RealArray + Handle(TDataStd_RealArray) aRealArrAtt = new TDataStd_RealArray(); + aLab.AddAttribute(aRealArrAtt); + if(!aRealArrAtt.IsNull()) { + Standard_GUID aGuid = aRealArrAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //13. Set TDataStd_RealList + Handle(TDataStd_RealList) aRealListAtt = new TDataStd_RealList(); + aLab.AddAttribute(aRealListAtt); + if(!aRealListAtt.IsNull()) { + Standard_GUID aGuid = aRealListAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //14. Set TDataStd_ReferenceArray + Handle(TDataStd_ReferenceArray) aRefArrAtt = new TDataStd_ReferenceArray(); + aLab.AddAttribute(aRefArrAtt); + if(!aRefArrAtt.IsNull()) { + Standard_GUID aGuid = aRefArrAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + + //15. Set TDataStd_ReferenceList + Handle(TDataStd_ReferenceList) aRefListAtt = new TDataStd_ReferenceList(); + aLab.AddAttribute(aRefListAtt); + if(!aRefListAtt.IsNull()) { + Standard_GUID aGuid = aRefListAtt->ID(); + IsNullGuid = IsSameGuid(aNullGuid, aGuid); + } + } catch (...) + { + IsNullGuid = Standard_True; + } + QCOMPARE (IsNullGuid, Standard_False); + anApp->Close(aDoc); + return 0; +} + void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2619,6 +2797,6 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { __FILE__, OCC28887, group); theCommands.Add("OCC28131", "OCC28131 name: creates face problematic for offset", __FILE__, OCC28131, group); theCommands.Add("OCC29289", "OCC29289 : searching trigonometric root by Newton iterations", __FILE__, OCC29289, group); - + theCommands.Add ("OCC29371", "OCC29371", __FILE__, OCC29371, group); return; } diff --git a/src/TDataStd/TDataStd_AsciiString.cxx b/src/TDataStd/TDataStd_AsciiString.cxx index a5f1e792e7..1db415b107 100644 --- a/src/TDataStd/TDataStd_AsciiString.cxx +++ b/src/TDataStd/TDataStd_AsciiString.cxx @@ -28,7 +28,7 @@ IMPLEMENT_STANDARD_RTTIEXT(TDataStd_AsciiString,TDF_Attribute) //function : TDataStd_AsciiString //purpose : //======================================================================= -TDataStd_AsciiString::TDataStd_AsciiString() +TDataStd_AsciiString::TDataStd_AsciiString(): myID(GetID()) { myString.Clear(); } diff --git a/src/TDataStd/TDataStd_BooleanArray.cxx b/src/TDataStd/TDataStd_BooleanArray.cxx index b1e0b2d28a..eb82bba595 100644 --- a/src/TDataStd/TDataStd_BooleanArray.cxx +++ b/src/TDataStd/TDataStd_BooleanArray.cxx @@ -87,10 +87,8 @@ static Handle(TDataStd_BooleanArray) SetAttr(const TDF_Label& label, //function : TDataStd_BooleanArray //purpose : Empty Constructor //======================================================================= -TDataStd_BooleanArray::TDataStd_BooleanArray() -{ - -} +TDataStd_BooleanArray::TDataStd_BooleanArray() : myID(GetID()) +{} //======================================================================= //function : Init diff --git a/src/TDataStd/TDataStd_BooleanList.cxx b/src/TDataStd/TDataStd_BooleanList.cxx index 317cf0b886..086cbfd9ab 100644 --- a/src/TDataStd/TDataStd_BooleanList.cxx +++ b/src/TDataStd/TDataStd_BooleanList.cxx @@ -55,10 +55,8 @@ static Handle(TDataStd_BooleanList) SetAttr(const TDF_Label& label, //function : TDataStd_BooleanList //purpose : Empty Constructor //======================================================================= -TDataStd_BooleanList::TDataStd_BooleanList() -{ - -} +TDataStd_BooleanList::TDataStd_BooleanList() : myID(GetID()) +{} //======================================================================= //function : Set diff --git a/src/TDataStd/TDataStd_ByteArray.cxx b/src/TDataStd/TDataStd_ByteArray.cxx index b886c55105..e29d5777cd 100644 --- a/src/TDataStd/TDataStd_ByteArray.cxx +++ b/src/TDataStd/TDataStd_ByteArray.cxx @@ -40,7 +40,8 @@ const Standard_GUID& TDataStd_ByteArray::GetID() //function : TDataStd_ByteArray //purpose : Empty Constructor //======================================================================= -TDataStd_ByteArray::TDataStd_ByteArray() : myIsDelta(Standard_False) +TDataStd_ByteArray::TDataStd_ByteArray() : myIsDelta(Standard_False), + myID(GetID()) {} //======================================================================= diff --git a/src/TDataStd/TDataStd_ExtStringArray.cxx b/src/TDataStd/TDataStd_ExtStringArray.cxx index a25618c494..a6df6da0c8 100644 --- a/src/TDataStd/TDataStd_ExtStringArray.cxx +++ b/src/TDataStd/TDataStd_ExtStringArray.cxx @@ -68,8 +68,9 @@ Handle(TDataStd_ExtStringArray) SetAttr(const TDF_Label& label, //======================================================================= TDataStd_ExtStringArray::TDataStd_ExtStringArray() - : myIsDelta(Standard_False){} - + : myIsDelta(Standard_False), myID(GetID()) +{} + //======================================================================= //function : Init //purpose : diff --git a/src/TDataStd/TDataStd_ExtStringList.cxx b/src/TDataStd/TDataStd_ExtStringList.cxx index 5d96fed21b..15b7257223 100644 --- a/src/TDataStd/TDataStd_ExtStringList.cxx +++ b/src/TDataStd/TDataStd_ExtStringList.cxx @@ -56,7 +56,7 @@ static Handle(TDataStd_ExtStringList) SetAttr(const TDF_Label& label, //function : TDataStd_ExtStringList //purpose : Empty Constructor //======================================================================= -TDataStd_ExtStringList::TDataStd_ExtStringList() +TDataStd_ExtStringList::TDataStd_ExtStringList() : myID(GetID()) {} //======================================================================= diff --git a/src/TDataStd/TDataStd_Integer.cxx b/src/TDataStd/TDataStd_Integer.cxx index 5c1077bf7b..36d42a1baf 100644 --- a/src/TDataStd/TDataStd_Integer.cxx +++ b/src/TDataStd/TDataStd_Integer.cxx @@ -82,7 +82,7 @@ Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L, //======================================================================= TDataStd_Integer::TDataStd_Integer () - : myValue (-1) + : myValue (-1), myID(GetID()) { } diff --git a/src/TDataStd/TDataStd_IntegerArray.cxx b/src/TDataStd/TDataStd_IntegerArray.cxx index d2c3c6dc40..f2772ef651 100644 --- a/src/TDataStd/TDataStd_IntegerArray.cxx +++ b/src/TDataStd/TDataStd_IntegerArray.cxx @@ -69,7 +69,7 @@ static Handle(TDataStd_IntegerArray) SetAttr(const TDF_Label& label, //======================================================================= TDataStd_IntegerArray::TDataStd_IntegerArray() - :myIsDelta(Standard_False) + :myIsDelta(Standard_False), myID(GetID()) {} //======================================================================= diff --git a/src/TDataStd/TDataStd_IntegerList.cxx b/src/TDataStd/TDataStd_IntegerList.cxx index b6cebb263b..f651ba62e4 100644 --- a/src/TDataStd/TDataStd_IntegerList.cxx +++ b/src/TDataStd/TDataStd_IntegerList.cxx @@ -55,10 +55,8 @@ static Handle(TDataStd_IntegerList) SetAttr(const TDF_Label& label, //function : TDataStd_IntegerList //purpose : Empty Constructor //======================================================================= -TDataStd_IntegerList::TDataStd_IntegerList() -{ - -} +TDataStd_IntegerList::TDataStd_IntegerList() : myID(GetID()) +{} //======================================================================= //function : Set diff --git a/src/TDataStd/TDataStd_Name.cxx b/src/TDataStd/TDataStd_Name.cxx index 977b42d311..b0e091ac01 100644 --- a/src/TDataStd/TDataStd_Name.cxx +++ b/src/TDataStd/TDataStd_Name.cxx @@ -85,7 +85,7 @@ Handle(TDataStd_Name) TDataStd_Name::Set (const TDF_Label& label, //purpose : Empty Constructor //======================================================================= -TDataStd_Name::TDataStd_Name () +TDataStd_Name::TDataStd_Name () : myID(GetID()) {} //======================================================================= diff --git a/src/TDataStd/TDataStd_Real.cxx b/src/TDataStd/TDataStd_Real.cxx index 4f4f229983..c4e9449cc4 100644 --- a/src/TDataStd/TDataStd_Real.cxx +++ b/src/TDataStd/TDataStd_Real.cxx @@ -84,7 +84,8 @@ Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L, TDataStd_Real::TDataStd_Real () : myValue (RealFirst()), - myDimension (TDataStd_SCALAR) + myDimension (TDataStd_SCALAR), + myID(GetID()) {} diff --git a/src/TDataStd/TDataStd_RealArray.cxx b/src/TDataStd/TDataStd_RealArray.cxx index 77723ce73d..760e5adaa9 100644 --- a/src/TDataStd/TDataStd_RealArray.cxx +++ b/src/TDataStd/TDataStd_RealArray.cxx @@ -68,7 +68,8 @@ static Handle(TDataStd_RealArray) SetAttr(const TDF_Label& label, //purpose : Empty Constructor //======================================================================= -TDataStd_RealArray::TDataStd_RealArray() : myIsDelta(Standard_False) +TDataStd_RealArray::TDataStd_RealArray() : myIsDelta(Standard_False), + myID(GetID()) {} //======================================================================= diff --git a/src/TDataStd/TDataStd_RealList.cxx b/src/TDataStd/TDataStd_RealList.cxx index ee81d64a76..2f59dfde77 100644 --- a/src/TDataStd/TDataStd_RealList.cxx +++ b/src/TDataStd/TDataStd_RealList.cxx @@ -55,10 +55,8 @@ static Handle(TDataStd_RealList) SetAttr(const TDF_Label& label, //function : TDataStd_RealList //purpose : Empty Constructor //======================================================================= -TDataStd_RealList::TDataStd_RealList() -{ - -} +TDataStd_RealList::TDataStd_RealList() : myID(GetID()) +{} //======================================================================= //function : Set diff --git a/src/TDataStd/TDataStd_ReferenceArray.cxx b/src/TDataStd/TDataStd_ReferenceArray.cxx index 19dd652eaf..abf6fd4574 100644 --- a/src/TDataStd/TDataStd_ReferenceArray.cxx +++ b/src/TDataStd/TDataStd_ReferenceArray.cxx @@ -62,10 +62,8 @@ static Handle(TDataStd_ReferenceArray) SetAttr(const TDF_Label& label, //function : TDataStd_ReferenceArray //purpose : Empty Constructor //======================================================================= -TDataStd_ReferenceArray::TDataStd_ReferenceArray() -{ - -} +TDataStd_ReferenceArray::TDataStd_ReferenceArray() : myID(GetID()) +{} //======================================================================= //function : Init diff --git a/src/TDataStd/TDataStd_ReferenceList.cxx b/src/TDataStd/TDataStd_ReferenceList.cxx index 98b44137b6..6243d13ed5 100644 --- a/src/TDataStd/TDataStd_ReferenceList.cxx +++ b/src/TDataStd/TDataStd_ReferenceList.cxx @@ -56,10 +56,8 @@ static Handle(TDataStd_ReferenceList) SetAttr(const TDF_Label& label, //function : TDataStd_ReferenceList //purpose : Empty Constructor //======================================================================= -TDataStd_ReferenceList::TDataStd_ReferenceList() -{ - -} +TDataStd_ReferenceList::TDataStd_ReferenceList() : myID(GetID()) +{} //======================================================================= //function : Set diff --git a/tests/bugs/caf/bug29371 b/tests/bugs/caf/bug29371 new file mode 100644 index 0000000000..cecfcba09a --- /dev/null +++ b/tests/bugs/caf/bug29371 @@ -0,0 +1,8 @@ +puts "===========" +puts "OCC29371" +puts "===========" + +pload QAcommands + +OCC29371 +