summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp16
-rw-r--r--fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h10
2 files changed, 10 insertions, 16 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;
diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
index ed4c8727fc..c83c770f97 100644
--- a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
+++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
@@ -27,12 +27,13 @@ class CXFA_FFDocHandler;
class CPDFXFA_Document : public IXFA_DocProvider {
public:
- CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider);
+ CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc,
+ CPDFXFA_App* pProvider);
~CPDFXFA_Document() override;
FX_BOOL LoadXFADoc();
CPDFXFA_App* GetApp() { return m_pApp; }
- CPDF_Document* GetPDFDoc() { return m_pPDFDoc; }
+ CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); }
CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); }
CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; }
@@ -200,7 +201,10 @@ class CPDFXFA_Document : public IXFA_DocProvider {
}
int m_iDocType;
- CPDF_Document* m_pPDFDoc;
+
+ // |m_pSDKDoc| has to be released before |m_pPDFDoc| since it needs to access
+ // it to kill focused annotations.
+ std::unique_ptr<CPDF_Document> m_pPDFDoc;
std::unique_ptr<CPDFSDK_Document> m_pSDKDoc;
std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
CXFA_FFDocView* m_pXFADocView; // not owned.