[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 1621
Date       : Mon Jul 31 16:35:29 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/node.cpp

Initialise Tag in attaching Node constructor and test for validity after calling AttachNode.


Diff:
Index: Trunk/XaraLX/Kernel/node.cpp
===================================================================
--- Trunk/XaraLX/Kernel/node.cpp	(revision 1620)
+++ Trunk/XaraLX/Kernel/node.cpp	(revision 1621)
@@ -249,23 +249,26 @@
 	Flags.SelectedChildren = FALSE;
 	Flags.Renderable = Renderable;
 	Flags.OpPermission1 = Flags.OpPermission2 = FALSE; // because SetOpPermission does a GetOpPermission
+
+	// Has no TAG because it is not in a document yet.
+	Tag = TAG_NOT_IN_DOC; 
+
 	SetOpPermission(PERMISSION_UNDEFINED);	
 	Child=NULL;                         // New node has no children
 	AttachNode(ContextNode,Direction);  
 			 
-	// Produce unique TAG for object 
-	//ENSURE(Document::GetCurrent() != NULL,"Unable to produce a unique TAG for the node" 
-	//	"
being constructed because the current document is NULL"); 
-	
+	// Sanity check of unique TAG for object
 	BaseDocument* pDoc = ContextNode->FindOwnerDoc();
 	if (pDoc != NULL)
 	{
+		ERROR3IF(Tag==TAG_NOT_IN_DOC, "Tag should have a valid value");
 		// Get a tag for this node and update the count of nodes in the document.
-		Tag = pDoc->NewTag();
-		pDoc->IncNodeCount();
+		if (Tag==TAG_NOT_IN_DOC)
+			SetTags(pDoc);
 	}
 	else 
 	{
+		ERROR3IF(Tag!=TAG_NOT_IN_DOC, "Tag should be TAG_NOT_IN_DOC");
 		Tag = TAG_NOT_IN_DOC; // Has no TAG
 	}
 


Xara