From d01cc61d44232d895a607a321f20de6770da34e1 Mon Sep 17 00:00:00 2001 From: szy Date: Thu, 10 Apr 2014 17:50:49 +0400 Subject: [PATCH] 0024755: TDF_Label::AddAttribute() reverses the order of added attributes Test case and new draw command for issue CR24755 Fix of regression linked with test case bug24047. Fix of bug361 regression on Linux. --- src/QABugs/QABugs_1.cxx | 2 +- src/QABugs/QABugs_19.cxx | 34 ++++++++++++++++++++++++++++++++++ src/TDF/TDF_Label.cxx | 5 +++++ src/XDEDRAW/XDEDRAW.cxx | 9 +-------- tests/bugs/caf/bug24755 | 7 +++++++ tests/bugs/caf/bug361 | 2 ++ 6 files changed, 50 insertions(+), 9 deletions(-) create mode 100755 tests/bugs/caf/bug24755 diff --git a/src/QABugs/QABugs_1.cxx b/src/QABugs/QABugs_1.cxx index 09e75cc514..73e5f95a06 100644 --- a/src/QABugs/QABugs_1.cxx +++ b/src/QABugs/QABugs_1.cxx @@ -486,7 +486,7 @@ static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, co TopoDS_Shape aTBox = aBox.Shape(); aTBox.Orientation(TopAbs_FORWARD); - TDF_Label aTestLabel = D->GetData()->Root(); + TDF_Label aTestLabel = D->Main(); TNaming_Builder aBuilder(aTestLabel); aBuilder.Generated(aTBox); diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 764e215c6b..6abcf8525d 100755 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -2079,6 +2079,39 @@ static Standard_Integer OCC24565 (Draw_Interpretor& di, Standard_Integer argc, c return 0; } +#include +#include +#include +#include +//======================================================================= +//function : OCC24755 +//purpose : +//======================================================================= +static Standard_Integer OCC24755 (Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + if (n != 1) + { + std::cout << "Usage : " << a[0] << "\n"; + return 1; + } + + Handle(TDocStd_Application) anApp = new AppStdL_Application; + Handle(TDocStd_Document) aDoc; + anApp->NewDocument ("MDTV-Standard", aDoc); + TDF_Label aLab = aDoc->Main(); + TDataStd_Integer::Set (aLab, 0); + TDataStd_Name::Set (aLab, "test"); + + TDF_AttributeIterator i (aLab); + Handle(TDF_Attribute) anAttr = i.Value(); + QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Integer)), Standard_True); + i.Next(); + anAttr = i.Value(); + QCOMPARE (anAttr->IsKind (STANDARD_TYPE (TDataStd_Name)), Standard_True); + + return 0; +} + void QABugs::Commands_19(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2118,5 +2151,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group); theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group); theCommands.Add ("OCC24565", "OCC24565 FileNameIGS FileNameSTOR", __FILE__, OCC24565, group); + theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group); return; } diff --git a/src/TDF/TDF_Label.cxx b/src/TDF/TDF_Label.cxx index 3e04b9aa1b..9208475af6 100644 --- a/src/TDF/TDF_Label.cxx +++ b/src/TDF/TDF_Label.cxx @@ -550,7 +550,12 @@ void TDF_Label::AddToNode (const TDF_LabelNodePtr& toNode, anAttribute->myTransaction = toNode->Data()->Transaction(); /// myData->Transaction(); anAttribute->mySavedTransaction = 0; + + //append to the end of the attribute list dummyAtt.Nullify(); + for (TDF_AttributeIterator itr (toNode); itr.More(); itr.Next()) + dummyAtt = itr.Value(); + toNode->AddAttribute(dummyAtt,anAttribute); toNode->AttributesModified(anAttribute->myTransaction != 0); //if (myData->NotUndoMode()) anAttribute->AfterAddition(); diff --git a/src/XDEDRAW/XDEDRAW.cxx b/src/XDEDRAW/XDEDRAW.cxx index 5061cdf2cc..4087902c78 100644 --- a/src/XDEDRAW/XDEDRAW.cxx +++ b/src/XDEDRAW/XDEDRAW.cxx @@ -1051,15 +1051,8 @@ static Standard_Integer testDoc (Draw_Interpretor&, TPrsStd_AISViewer::Update(aLab); aContext->Display(aTriShape, Standard_True); - Handle(TDocStd_Owner) owner; - if (aD1->Main().Root().FindAttribute(TDocStd_Owner::GetID(), owner)) - { - Handle_TDocStd_Document empty; - owner->SetDocument(empty); - } - aContext.Nullify(); + aD1->BeforeClose(); aD1->Close(); - aD1.Nullify(); return 0; } diff --git a/tests/bugs/caf/bug24755 b/tests/bugs/caf/bug24755 new file mode 100755 index 0000000000..dace57f3f9 --- /dev/null +++ b/tests/bugs/caf/bug24755 @@ -0,0 +1,7 @@ +puts "===========" +puts "OCC24755" +puts "===========" + +pload QAcommands + +OCC24755 diff --git a/tests/bugs/caf/bug361 b/tests/bugs/caf/bug361 index 216c128128..51aacc942b 100755 --- a/tests/bugs/caf/bug361 +++ b/tests/bugs/caf/bug361 @@ -11,3 +11,5 @@ if { [catch { OCC361 D }] } { puts "OCC361: Error" } +Close D + -- 2.20.1