summaryrefslogtreecommitdiff
path: root/samples
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 /samples
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 'samples')
-rw-r--r--samples/pdfium_test.cc19
1 files changed, 4 insertions, 15 deletions
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<FPDF_FORMFILLINFO_PDFiumTest*>(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)