From f716f0bd85cabfa02cea1d092890a0dea67ef0e3 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 30 Jan 2017 10:04:07 -0800 Subject: Refcount CPDF_OCContext. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids explicit deletes through CPDF_RenderOptions holding pointers to it which may have been copy constructed. Ick. Change-Id: Ic044b66d13bd7c5eaa53de995373858081e115ec Reviewed-on: https://pdfium-review.googlesource.com/2451 Reviewed-by: dsinclair Reviewed-by: Nicolás Peña Commit-Queue: Tom Sepez --- fpdfsdk/fpdfformfill.cpp | 9 ++++----- fpdfsdk/fpdfview.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 6b8cbaa59d..beebe65dbb 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -127,12 +127,13 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, options.m_bDrawAnnots = flags & FPDF_ANNOT; #ifdef PDF_ENABLE_XFA - options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View); + options.m_pOCContext = + pdfium::MakeRetain(pPDFDoc, CPDF_OCContext::View); if (CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); #else // PDF_ENABLE_XFA - options.m_pOCContext = - new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View); + options.m_pOCContext = pdfium::MakeRetain( + pPage->m_pDocument, CPDF_OCContext::View); if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); #endif // PDF_ENABLE_XFA @@ -142,8 +143,6 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, pDevice->Flush(); CFXBitmapFromFPDFBitmap(bitmap)->UnPreMultiply(); #endif - delete options.m_pOCContext; - options.m_pOCContext = nullptr; } } // namespace diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index ff4d46e357..c1dc0df73e 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -94,7 +94,7 @@ void RenderPageImpl(CPDF_PageRenderContext* pContext, (flags & FPDF_PRINTING) ? CPDF_OCContext::Print : CPDF_OCContext::View; pContext->m_pOptions->m_AddFlags = flags >> 8; pContext->m_pOptions->m_pOCContext = - new CPDF_OCContext(pPage->m_pDocument, usage); + pdfium::MakeRetain(pPage->m_pDocument, usage); pContext->m_pDevice->SaveState(); pContext->m_pDevice->SetClip_Rect(clipping_rect); -- cgit v1.2.3