summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_ffdoc.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-28 09:31:32 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-28 16:42:55 +0000
commitf0799fe84df4d86f25d342b03525f3016d674f86 (patch)
treed6839802a68b7b6ad6fb166179ede779c3560c75 /xfa/fxfa/cxfa_ffdoc.cpp
parent31b08d4cdaa17d7a03f35e087096a77036af98ec (diff)
downloadpdfium-f0799fe84df4d86f25d342b03525f3016d674f86.tar.xz
Revert "Revert "Refcount all CFX_DIBSources (and subclasses) all the time.""
This reverts commit 31b08d4cdaa17d7a03f35e087096a77036af98ec. Re-landing the patch after fixing skia build issue. Change-Id: Ie7039890088b803a6ec5ce365d70f57277459b48 Reviewed-on: https://pdfium-review.googlesource.com/3245 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_ffdoc.cpp')
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index fdeacf7f0f..e14500a725 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -332,10 +332,6 @@ bool CXFA_FFDoc::CloseDoc() {
m_DocView.reset();
m_pNotify.reset(nullptr);
m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this);
-
- for (const auto& pair : m_HashToDibDpiMap)
- delete pair.second.pDibSource;
-
m_HashToDibDpiMap.clear();
m_pApp->ClearEventTargets();
return true;
@@ -345,9 +341,10 @@ CPDF_Document* CXFA_FFDoc::GetPDFDoc() {
return m_pPDFDoc;
}
-CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
- int32_t& iImageXDpi,
- int32_t& iImageYDpi) {
+CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
+ const CFX_WideStringC& wsName,
+ int32_t& iImageXDpi,
+ int32_t& iImageYDpi) {
if (!m_pPDFDoc)
return nullptr;
@@ -356,7 +353,7 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
if (it != m_HashToDibDpiMap.end()) {
iImageXDpi = it->second.iImageXDpi;
iImageYDpi = it->second.iImageYDpi;
- return static_cast<CFX_DIBitmap*>(it->second.pDibSource);
+ return it->second.pDibSource.As<CFX_DIBitmap>();
}
CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
@@ -396,7 +393,7 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
IFX_MemoryStream::Create((uint8_t*)streamAcc.GetData(),
streamAcc.GetSize());
- CFX_DIBitmap* pDibSource = XFA_LoadImageFromBuffer(
+ CFX_RetainPtr<CFX_DIBitmap> pDibSource = XFA_LoadImageFromBuffer(
pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi};
return pDibSource;