summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-08-24 11:12:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-24 11:12:19 -0700
commitcedaa557316a3f5c436814e69d67f19795f471d7 (patch)
tree128140994288bcd5b01f578e9dafc4bf1ea87493 /fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
parentade4b495433751ac853f2d677b9e1da94d0d6bf7 (diff)
downloadpdfium-cedaa557316a3f5c436814e69d67f19795f471d7.tar.xz
Flip document and parser ownership
This Cl switches the ownership between the parser and the document. Previously the parser owned the document and we'd jump through hoops during cleanup to delete the right object. This Cl flips the ownership so the document owns the parser and simplifies the cleanup logic where needed. BUG=pdfium:565 Review-Url: https://codereview.chromium.org/2275773003
Diffstat (limited to 'fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp')
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index 605e53c32a..d4c43c5706 100644
--- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -45,10 +45,10 @@ extern void SetLastError(int err);
extern int GetLastError();
#endif
-CPDFXFA_Document::CPDFXFA_Document(CPDF_Document* pPDFDoc,
+CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc,
CPDFXFA_App* pProvider)
: m_iDocType(DOCTYPE_PDF),
- m_pPDFDoc(pPDFDoc),
+ m_pPDFDoc(std::move(pPDFDoc)),
m_pXFADocView(nullptr),
m_pApp(pProvider),
m_pJSContext(nullptr),
@@ -70,16 +70,6 @@ CPDFXFA_Document::~CPDFXFA_Document() {
}
if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv())
m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
- // |m_pSDKDoc| has to be released before |pParser| and |m_pPDFDoc| since it
- // needs to access them to kill focused annotations.
- m_pSDKDoc.reset();
- if (m_pPDFDoc) {
- CPDF_Parser* pParser = m_pPDFDoc->GetParser();
- if (pParser)
- delete pParser;
- else
- delete m_pPDFDoc;
- }
m_nLoadStatus = FXFA_LOADSTATUS_CLOSED;
}
@@ -96,7 +86,7 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc() {
if (!pApp)
return FALSE;
- m_pXFADoc.reset(pApp->CreateDoc(this, m_pPDFDoc));
+ m_pXFADoc.reset(pApp->CreateDoc(this, m_pPDFDoc.get()));
if (!m_pXFADoc) {
SetLastError(FPDF_ERR_XFALOAD);
return FALSE;