From 8509d3eaec1b2fac27a24de7bc586ad12b7bb178 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 4 Dec 2017 06:13:55 +0000 Subject: Make a CXFA_DocumentParser member Unowned. Fix/cleanup ctors/dtors in related classes. Change-Id: Ia05ec9b6892fd7d19d0a417fc1226a407e3ac260 Reviewed-on: https://pdfium-review.googlesource.com/20216 Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 9 ++------- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 6 +++--- xfa/fxfa/cxfa_ffdoc.cpp | 8 ++------ xfa/fxfa/cxfa_ffdoc.h | 4 ++-- xfa/fxfa/parser/cxfa_document_parser.cpp | 2 +- xfa/fxfa/parser/cxfa_document_parser.h | 2 +- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index 4b67d0cf3f..d05e2f6b34 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -36,14 +36,9 @@ extern int GetLastError(); #endif CPDFXFA_Context::CPDFXFA_Context(std::unique_ptr pPDFDoc) - : m_FormType(FormType::kNone), - m_pPDFDoc(std::move(pPDFDoc)), - m_pFormFillEnv(nullptr), - m_pXFADocView(nullptr), - m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD), - m_nPageCount(0), + : m_pPDFDoc(std::move(pPDFDoc)), + m_pXFAApp(pdfium::MakeUnique(this)), m_DocEnv(this) { - m_pXFAApp = pdfium::MakeUnique(this); m_pXFAApp->SetDefaultFontMgr(pdfium::MakeUnique()); } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index f5b62f53da..acef8f2aa8 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -105,7 +105,7 @@ class CPDFXFA_Context : public IXFA_AppProvider { private: void CloseXFADoc(); - FormType m_FormType; + FormType m_FormType = FormType::kNone; std::unique_ptr m_pPDFDoc; std::unique_ptr m_pXFADoc; Observable::ObservedPtr m_pFormFillEnv; @@ -113,8 +113,8 @@ class CPDFXFA_Context : public IXFA_AppProvider { std::unique_ptr m_pXFAApp; std::unique_ptr m_pRuntime; std::vector> m_XFAPageList; - LoadStatus m_nLoadStatus; - int m_nPageCount; + LoadStatus m_nLoadStatus = FXFA_LOADSTATUS_PRELOAD; + int m_nPageCount = 0; // Must be destroyed before |m_pFormFillEnv|. CPDFXFA_DocEnvironment m_DocEnv; diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index bf8168d4cc..8ca1e95d87 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -155,12 +155,7 @@ int32_t Base64DecodeW(const wchar_t* pSrc, int32_t iSrcLen, uint8_t* pDst) { } // namespace CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment) - : m_pDocEnvironment(pDocEnvironment), - m_pDocumentParser(nullptr), - m_pApp(pApp), - m_pNotify(nullptr), - m_pPDFDoc(nullptr), - m_FormType(FormType::kXFAForeground) {} + : m_pDocEnvironment(pDocEnvironment), m_pApp(pApp) {} CXFA_FFDoc::~CXFA_FFDoc() { CloseDoc(); @@ -328,6 +323,7 @@ void CXFA_FFDoc::CloseDoc() { if (doc) doc->ClearLayoutData(); + m_pDocumentParser.reset(); m_pNotify.reset(); m_pPDFFontMgr.reset(); m_HashToDibDpiMap.clear(); diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h index 10ffa36275..475ead3035 100644 --- a/xfa/fxfa/cxfa_ffdoc.h +++ b/xfa/fxfa/cxfa_ffdoc.h @@ -85,13 +85,13 @@ class CXFA_FFDoc { UnownedPtr const m_pDocEnvironment; std::unique_ptr m_pDocumentParser; RetainPtr m_pStream; - UnownedPtr m_pApp; + UnownedPtr const m_pApp; std::unique_ptr m_pNotify; UnownedPtr m_pPDFDoc; std::map m_HashToDibDpiMap; std::unique_ptr m_DocView; std::unique_ptr m_pPDFFontMgr; - FormType m_FormType; + FormType m_FormType = FormType::kXFAForeground; }; #endif // XFA_FXFA_CXFA_FFDOC_H_ diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index df7d789781..6446ea31ce 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -45,7 +45,7 @@ CFX_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { } CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { - return m_pNotify; + return m_pNotify.Get(); } CXFA_Document* CXFA_DocumentParser::GetDocument() const { diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h index 6629101457..35d71603cb 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.h +++ b/xfa/fxfa/parser/cxfa_document_parser.h @@ -31,7 +31,7 @@ class CXFA_DocumentParser { CXFA_Document* GetDocument() const; private: - CXFA_FFNotify* const m_pNotify; + UnownedPtr const m_pNotify; std::unique_ptr m_pDocument; CXFA_SimpleParser m_nodeParser; }; -- cgit v1.2.3