Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp

Issue 2275773003: Flip document and parser ownership (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@private_parser
Patch Set: Rebase to master Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/fpdfview.cpp ('k') | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index 605e53c32a94e5773c9d123114bc0d80bacc12db..d4c43c570679c9c22f2b8732600e718f76ca4145 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;
« no previous file with comments | « fpdfsdk/fpdfview.cpp ('k') | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698