From 69dcf148b3755c11d5da47fbee767aa920ee2f58 Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Tue, 16 Sep 2014 13:24:37 -0700 Subject: When forcing clear page data, no need to release colorspace when releasing pattern BUG=414661 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/572853006 --- core/include/fpdfapi/fpdf_resource.h | 3 ++- core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp | 1 + core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h index a7a644435e..937024c94e 100644 --- a/core/include/fpdfapi/fpdf_resource.h +++ b/core/include/fpdfapi/fpdf_resource.h @@ -730,6 +730,7 @@ class CPDF_Pattern : public CFX_Object public: virtual ~CPDF_Pattern(); + void SetForceClear(FX_BOOL bForceClear) { m_bForceClear = bForceClear; } CPDF_Object* m_pPatternObj; @@ -741,8 +742,8 @@ public: CPDF_Document* m_pDocument; protected: - CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix); + FX_BOOL m_bForceClear; }; class CPDF_TilingPattern : public CPDF_Pattern diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp index 131edbe9b5..77db4534fb 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_doc.cpp @@ -229,6 +229,7 @@ void CPDF_DocPageData::Clear(FX_BOOL bForceRelease) m_PatternMap.GetNextAssoc(pos, ptObj, ptData); nCount = ptData->m_nCount; if (bForceRelease || nCount < 2) { + ptData->m_Obj->SetForceClear(bForceRelease); delete ptData->m_Obj; ptData->m_Obj = NULL; } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp index bcb8196662..67ea4fee65 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp @@ -8,7 +8,7 @@ #include "pageint.h" CPDF_Pattern::CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix) : - m_pPatternObj(NULL), m_PatternType(PATTERN_TILING), m_pDocument(NULL) + m_pPatternObj(NULL), m_PatternType(PATTERN_TILING), m_pDocument(NULL), m_bForceClear(FALSE) { if (pParentMatrix) { m_ParentMatrix = *pParentMatrix; @@ -97,7 +97,7 @@ void CPDF_ShadingPattern::Clear() m_pFunctions[i] = NULL; } CPDF_ColorSpace* pCS = m_pCS; - if (pCS && m_pDocument) { + if (!m_bForceClear && pCS && m_pDocument) { m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); } m_ShadingType = 0; -- cgit v1.2.3