From 80bf582f00adeefae67ae432b74c3b0609e7845e Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 13 Feb 2018 20:55:03 +0000 Subject: Cleanup CXFA_Node ownership Currently a CXFA_Node can be owned by the CXFA_Document root pointer, the CXFA_Document Purge list or as a child of another CXFA_Node. This makes it hard to know who currently owns what. This CL moves all ownership of nodes into a CXFA_NodeOwner class which CXFA_Document subclasses. The node owner always owns all nodes and is responsible for cleaning them up upon destruction. The destruction order is not guarenteed to be in tree order as nodes can be inserted and moved around the tree. Change-Id: I6b202b8e844999ba835093dcdd1a808938b6d9a8 Reviewed-on: https://pdfium-review.googlesource.com/26434 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fxjs/xfa/cjx_object.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fxjs/xfa') diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index d663fcce70..50643ffc5b 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -1261,7 +1261,7 @@ void CJX_Object::Script_Attribute_String(CFXJSE_Value* pValue, pHeadChild = pSibling; } - std::unique_ptr pProtoForm(pProtoNode->CloneTemplateToForm(true)); + CXFA_Node* pProtoForm = pProtoNode->CloneTemplateToForm(true); pHeadChild = pProtoForm->GetFirstChild(); while (pHeadChild) { CXFA_Node* pSibling = pHeadChild->GetNextSibling(); @@ -1269,8 +1269,8 @@ void CJX_Object::Script_Attribute_String(CFXJSE_Value* pValue, ToNode(GetXFAObject())->InsertChild(pHeadChild, nullptr); pHeadChild = pSibling; } - - GetDocument()->RemovePurgeNode(pProtoForm.get()); + GetDocument()->FreeOwnedNode(pProtoForm); + pProtoForm = nullptr; } void CJX_Object::Script_Attribute_BOOL(CFXJSE_Value* pValue, -- cgit v1.2.3