summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp6
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_document.cpp10
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_document.h8
3 files changed, 14 insertions, 10 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index 1b27e16551..fed5409624 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -258,7 +258,11 @@ FX_BOOL CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget,
void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView,
uint32_t dwFlags) {
- CPDFSDK_Environment* pEnv = m_pDocument->GetSDKDoc()->GetEnv();
+ CPDFSDK_Document* pSDKDoc = m_pDocument->GetSDKDoc();
+ if (!pSDKDoc)
+ return;
+
+ CPDFSDK_Environment* pEnv = pSDKDoc->GetEnv();
if (!pEnv)
return;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp
index e49cfde8c4..121d060453 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp
@@ -33,6 +33,7 @@ CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc,
CPDFXFA_App* pProvider)
: m_iDocType(DOCTYPE_PDF),
m_pPDFDoc(std::move(pPDFDoc)),
+ m_pSDKDoc(nullptr),
m_pXFADocView(nullptr),
m_pApp(pProvider),
m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD),
@@ -42,6 +43,11 @@ CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc,
CPDFXFA_Document::~CPDFXFA_Document() {
m_nLoadStatus = FXFA_LOADSTATUS_CLOSING;
+ if (m_pSDKDoc) {
+ m_pSDKDoc->ClearAllFocusedAnnots();
+ m_pSDKDoc = nullptr;
+ }
+
if (m_pXFADoc) {
CXFA_FFApp* pApp = m_pApp->GetXFAApp();
if (pApp) {
@@ -191,10 +197,6 @@ void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) {
m_XFAPageList.SetAt(page->GetPageIndex(), nullptr);
}
-void CPDFXFA_Document::SetSDKDoc(std::unique_ptr<CPDFSDK_Document> pSDKDoc) {
- m_pSDKDoc.reset(pSDKDoc.release());
-}
-
void CPDFXFA_Document::ClearChangeMark() {
if (m_pSDKDoc)
m_pSDKDoc->ClearChangeMark();
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_document.h b/fpdfsdk/fpdfxfa/cpdfxfa_document.h
index f67a880a36..fa415f917c 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_document.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_document.h
@@ -40,8 +40,8 @@ class CPDFXFA_Document {
CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; }
int GetDocType() const { return m_iDocType; }
- CPDFSDK_Document* GetSDKDoc() const { return m_pSDKDoc.get(); }
- void SetSDKDoc(std::unique_ptr<CPDFSDK_Document> pSDKDoc);
+ CPDFSDK_Document* GetSDKDoc() const { return m_pSDKDoc; }
+ void SetSDKDoc(CPDFSDK_Document* pSDKDoc) { m_pSDKDoc = pSDKDoc; }
void DeletePage(int page_index);
int GetPageCount() const;
@@ -78,10 +78,8 @@ class CPDFXFA_Document {
int m_iDocType;
std::unique_ptr<CPDF_Document> m_pPDFDoc;
- // |m_pSDKDoc| must be destroyed before |m_pPDFDoc| since it needs to access
- // it to kill focused annotations.
- std::unique_ptr<CPDFSDK_Document> m_pSDKDoc;
std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
+ CPDFSDK_Document* m_pSDKDoc; // not owned.
CXFA_FFDocView* m_pXFADocView; // not owned.
CPDFXFA_App* const m_pApp;
CFX_ArrayTemplate<CPDFXFA_Page*> m_XFAPageList;