From 2116105b7d0545eb353264d4b42420cf51af5195 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 5 Oct 2016 15:46:15 -0700 Subject: 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 --- samples/pdfium_test.cc | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'samples') diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 35e0d50678..5c0f81b1b0 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -86,19 +86,6 @@ static FPDF_FORMFILLINFO_PDFiumTest* ToPDFiumTestFormFillInfo( return static_cast(formFillInfo); } -static void CloseDocAndForm(FPDF_DOCUMENT doc, FPDF_FORMHANDLE form) { -#ifdef PDF_ENABLE_XFA - // Note: The shut down order here is the reverse of the non-XFA branch order. - // Need to work out if this is required, and if it is, the lifetimes of - // objects owned by |doc| that |form| reference. - FPDF_CloseDocument(doc); - FPDFDOC_ExitFormFillEnvironment(form); -#else // PDF_ENABLE_XFA - FPDFDOC_ExitFormFillEnvironment(form); - FPDF_CloseDocument(doc); -#endif // PDF_ENABLE_XFA -} - static bool CheckDimensions(int stride, int width, int height) { if (stride < 0 || width < 0 || height < 0) return false; @@ -791,7 +778,8 @@ void RenderPdf(const std::string& name, if (nRet == PDF_DATA_ERROR) { fprintf(stderr, "Unknown error in checking if page %d is available.\n", i); - CloseDocAndForm(doc, form); + FPDFDOC_ExitFormFillEnvironment(form); + FPDF_CloseDocument(doc); return; } } @@ -803,7 +791,8 @@ void RenderPdf(const std::string& name, FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); - CloseDocAndForm(doc, form); + FPDFDOC_ExitFormFillEnvironment(form); + FPDF_CloseDocument(doc); fprintf(stderr, "Rendered %d pages.\n", rendered_pages); if (bad_pages) -- cgit v1.2.3