0024755: TDF_Label::AddAttribute() reverses the order of added attributes
authorszy <szy@opencascade.com>
Thu, 10 Apr 2014 13:50:49 +0000 (17:50 +0400)
committerapn <apn@opencascade.com>
Thu, 10 Apr 2014 13:51:32 +0000 (17:51 +0400)
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
src/QABugs/QABugs_19.cxx
src/TDF/TDF_Label.cxx
src/XDEDRAW/XDEDRAW.cxx
tests/bugs/caf/bug24755 [new file with mode: 0755]
tests/bugs/caf/bug361

index 09e75cc51421a5e6f68720e4ca6dacafc70d957f..73e5f95a0614abe9d285cc215ea53d2771640bc8 100644 (file)
@@ -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);
index 764e215c6b7d52fec22a621e75d9dd4a6343c283..6abcf8525d1d0fefeecb4c220376152774c20862 100755 (executable)
@@ -2079,6 +2079,39 @@ static Standard_Integer OCC24565 (Draw_Interpretor& di, Standard_Integer argc, c
   return 0;
 }
 
+#include <AppStdL_Application.hxx>
+#include <TDocStd_Application.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDF_AttributeIterator.hxx>
+//=======================================================================
+//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;
 }
index 3e04b9aa1b7cdc48c79bda8b49f078c12d05ba6c..9208475af668ab32ba4850322cffd46f4ebd417b 100644 (file)
@@ -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();  
index 5061cdf2cc2c45ac019dde49211e2623ccd840ff..4087902c78055b5909ee918fab4e721ffbb67643 100644 (file)
@@ -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 (executable)
index 0000000..dace57f
--- /dev/null
@@ -0,0 +1,7 @@
+puts "==========="
+puts "OCC24755"
+puts "==========="
+
+pload QAcommands
+
+OCC24755
index 216c1281280c64586d0e4200a08c905ac09021a8..51aacc942b20b7af94a4922688bce5e28a408434 100755 (executable)
@@ -11,3 +11,5 @@ if { [catch { OCC361 D }] } {
     puts "OCC361: Error"
 }
 
+Close D
+