summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfformfill.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-05 15:46:15 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-05 15:46:15 -0700
commit2116105b7d0545eb353264d4b42420cf51af5195 (patch)
tree959cb01c9d4049a9354657a7ea772b1c2860ab92 /fpdfsdk/fpdfformfill.cpp
parente883afcab15b17769bda0a1aac0f540568df3368 (diff)
downloadpdfium-2116105b7d0545eb353264d4b42420cf51af5195.tar.xz
Remove ownership of CPDFSDK_Document from CPDFXFA_Document
This CL updates CPDFXFA_Document so it never owns the CPDFSDK_Document. The CPDFSDK_Document is now always owned by the CPDFXFA_Environment. This also cleans up the strange need to reverse the order of document and form destruction when using XFA. Review-Url: https://codereview.chromium.org/2397473006
Diffstat (limited to 'fpdfsdk/fpdfformfill.cpp')
-rw-r--r--fpdfsdk/fpdfformfill.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 6fea1af42b..904a3c867e 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -254,8 +254,7 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo);
#ifdef PDF_ENABLE_XFA
- // Ownership of the SDKDocument is passed to the CPDFXFA_Document.
- pDocument->SetSDKDoc(pdfium::WrapUnique(pEnv->GetSDKDocument()));
+ pDocument->SetSDKDoc(pEnv->GetSDKDocument());
CPDFXFA_App::GetInstance()->AddFormFillEnv(pEnv);
#endif // PDF_ENABLE_XFA
@@ -271,10 +270,12 @@ FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
#ifdef PDF_ENABLE_XFA
CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pEnv);
-#else // PDF_ENABLE_XFA
+
+ // Reset the focused annotations and remove the SDK document from the
+ // XFA document.
if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) {
- pEnv->SetSDKDocument(nullptr);
- delete pSDKDoc;
+ pSDKDoc->ClearAllFocusedAnnots();
+ pSDKDoc->GetXFADocument()->SetSDKDoc(nullptr);
}
#endif // PDF_ENABLE_XFA