From 3857904e520ecb06bad545e4e4bfcf4e60dd1f52 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 16 May 2016 17:05:38 -0700 Subject: Remove Release() { delete this; } in CFXA_Data{Importer,Exporter} Review-Url: https://codereview.chromium.org/1988453002 --- xfa/fxfa/app/xfa_ffdoc.cpp | 41 ++++++++++++++------------------ xfa/fxfa/parser/xfa_document_serialize.h | 3 +-- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index f33e4e0585..8297dce9ec 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -362,34 +362,29 @@ CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { ? static_cast(pXMLNode) : NULL; } + FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, IFX_FileWrite* pFile, CXFA_ChecksumContext* pCSContext) { - CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument); + std::unique_ptr pExport( + new CXFA_DataExporter(m_pDocument)); uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); - CXFA_Node* pNode = NULL; - if (packetHash == XFA_HASHCODE_Xfa) { - pNode = m_pDocument->GetRoot(); - } else { - pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); - } - FX_BOOL bFlags = FALSE; - if (pNode) { - CFX_ByteString bsChecksum; - if (pCSContext) { - pCSContext->GetChecksum(bsChecksum); - } - bFlags = pExport->Export( - pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : NULL); - } else { - bFlags = pExport->Export(pFile); - } - pExport->Release(); - return bFlags; + CXFA_Node* pNode = packetHash == XFA_HASHCODE_Xfa + ? m_pDocument->GetRoot() + : ToNode(m_pDocument->GetXFAObject(packetHash)); + if (!pNode) + return pExport->Export(pFile); + + CFX_ByteString bsChecksum; + if (pCSContext) + pCSContext->GetChecksum(bsChecksum); + + return pExport->Export(pFile, pNode, 0, + bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); } -FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { - std::unique_ptr> - importer(new CXFA_DataImporter(m_pDocument)); +FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { + std::unique_ptr importer( + new CXFA_DataImporter(m_pDocument)); return importer->ImportData(pStream); } diff --git a/xfa/fxfa/parser/xfa_document_serialize.h b/xfa/fxfa/parser/xfa_document_serialize.h index 6448953231..9136efce90 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.h +++ b/xfa/fxfa/parser/xfa_document_serialize.h @@ -19,7 +19,6 @@ class CXFA_DataImporter { public: explicit CXFA_DataImporter(CXFA_Document* pDocument); - void Release() { delete this; } FX_BOOL ImportData(IFX_FileRead* pDataDocument); protected: @@ -30,7 +29,6 @@ class CXFA_DataExporter { public: explicit CXFA_DataExporter(CXFA_Document* pDocument); - void Release() { delete this; } FX_BOOL Export(IFX_FileWrite* pWrite); FX_BOOL Export(IFX_FileWrite* pWrite, CXFA_Node* pNode, @@ -42,6 +40,7 @@ class CXFA_DataExporter { CXFA_Node* pNode, uint32_t dwFlag, const FX_CHAR* pChecksum); + CXFA_Document* const m_pDocument; }; -- cgit v1.2.3