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

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 1484
Date       : Thu Jul 20 14:12:02 BST 2006

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

Fixes a bug found by MartinW concerning attribute promotion when only the caret is selected.


Diff:
Index: Trunk/XaraLX/Kernel/attrappl.cpp
===================================================================
--- Trunk/XaraLX/Kernel/attrappl.cpp	(revision 1483)
+++ Trunk/XaraLX/Kernel/attrappl.cpp	(revision 1484)
@@ -1444,6 +1444,8 @@
 		Node* CurrentNode = pLevel->FindFirst();
 		Node* FirstNode = CurrentNode;
 
+		BOOL bCanDiscardUndo = TRUE;
+
 		// While there are still nodes to apply the attribute to
 		while (CurrentNode != NULL)
 		{
@@ -1451,11 +1453,6 @@
 			Node* OldNode = CurrentNode;
 			CurrentNode = pLevel->FindNext(CurrentNode);
 
-			// If this is the only node in the selection and it discards attribute undo
-			// Then we can abandon the entire Op once it's finished
-			if (OldNode->DiscardsAttributeChildren() && OldNode==FirstNode && CurrentNode==NULL)
-				pOp->SucceedAndDiscard();
-
 			if (OldNode->IsAnObject())
 			{
 				// Scan up through the stack to find the appropriate level to apply this attribute
@@ -1472,9 +1469,13 @@
 						Node * pNextChildNode = pChildNode->FindNext();
 
 						if (pChildNode->IsAnObject() && ((NodeRenderableInk*)pChildNode)->RequiresAttrib(Attrib))
+						{
 							if (!DoApply(pOp, pChildNode, Attrib, bMutate, FALSE, TRUE, bOptimise, &bAttrWasRequired))	// Will only apply Attrib if the node requires it.
 								return FALSE; 
 
+							bCanDiscardUndo = bCanDiscardUndo && pChildNode->DiscardsAttributeChildren();
+						}
+
 						pChildNode = pNextChildNode;
 					}
 				}
@@ -1485,6 +1486,7 @@
 					{
 						return FALSE; 
 					}
+					bCanDiscardUndo = bCanDiscardUndo && OldNode->DiscardsAttributeChildren();
 				}
 
 
@@ -1506,6 +1508,7 @@
 				{
 					return FALSE; 
 				}
+				bCanDiscardUndo = bCanDiscardUndo && OldNode->DiscardsAttributeChildren();
 			}
 
 			// a bodge to handle the case when a line width is applied to a transparent line.
@@ -1550,6 +1553,8 @@
 					if (!DoApply(pOp, OldNode, pAttr, bMutate, FALSE, FALSE, bOptimise, &bAttrWasRequired))
 						continue; 
 
+					bCanDiscardUndo = bCanDiscardUndo && OldNode->DiscardsAttributeChildren();
+
 					// remove the attribute
 					delete pAttr;
 					pAttr = NULL;
@@ -1575,6 +1580,8 @@
 				{
 					if (!DoApply(pOp, pNextATChar, Attrib, bMutate, FALSE, TRUE, bOptimise, &bAttrWasRequired))
 						return FALSE; 
+
+					bCanDiscardUndo = bCanDiscardUndo && pNextATChar->DiscardsAttributeChildren();
 				}
 			}
 
@@ -1593,6 +1600,12 @@
 //				}
 //			}
 		}
+
+		// If all nodes report DiscardsAttributeChildren() = TRUE
+		// Then we can abandon the entire Op once it's finished
+		if (bCanDiscardUndo)
+			pOp->SucceedAndDiscard();
+
 	}
 	return TRUE;
 }
@@ -2589,6 +2602,8 @@
 	INT32 stackpos = STACKPOS_TOP;
 	Range* pLevel = pStack->GetLevelRange(&stackpos, FALSE);			// Don't escape old controllers, apply attr to base nodes
 
+	BOOL bCanDiscardUndo = TRUE;
+
 	NodeAttributePtrItem* pAttrItem = (NodeAttributePtrItem*)(Attribs->GetHead());
 	while (pAttrItem)
 	{
@@ -2621,11 +2636,6 @@
 				AttrToApply->TransformToNewBounds(NodeBounds);
 			}
 
-			// If this is the only node in the selection and it discards attribute undo
-			// Then we can abandon the entire Op once it's finished
-			if (CurrentNode->DiscardsAttributeChildren() && CurrentNode==FirstNode && pLevel->FindNext(CurrentNode)==NULL)
-				SucceedAndDiscard();
-
 			if (!DoApply(CurrentNode, 
 						 AttrToApply, 
 						 FALSE,  // Don't mutate
@@ -2636,6 +2646,8 @@
 				goto Failed;
 			}
 
+			bCanDiscardUndo = bCanDiscardUndo && CurrentNode->DiscardsAttributeChildren();
+
 			if (ThisAttrWasRequired)
 			{
 				*pAttribWasRequired = TRUE;
@@ -2690,6 +2702,11 @@
 		pAttrItem = (NodeAttributePtrItem*)(Attribs->GetNext(pAttrItem));
 	}
 
+	// If all nodes report DiscardsAttributeChildren() = TRUE
+	// Then we can abandon the entire Op once it's finished
+	if (bCanDiscardUndo)
+		SucceedAndDiscard();
+
 	return TRUE; 
 
 	Failed:


Xara