When forcing clear page data, no need to release colorspace when releasing pattern
[pdfium.git] / core / src / fpdfapi / fpdf_page / fpdf_page_doc.cpp
index 16f0a9c..77db453 100644 (file)
@@ -154,17 +154,6 @@ void CPDF_DocPageData::Clear(FX_BOOL bForceRelease)
     FX_DWORD   nCount;
 
     m_bForceClear = bForceRelease;
-    pos = m_PatternMap.GetStartPosition();
-    while (pos) {
-        CPDF_Object* ptObj;
-        CPDF_CountedObject<CPDF_Pattern*>* ptData;
-        m_PatternMap.GetNextAssoc(pos, ptObj, ptData);
-        nCount = ptData->m_nCount;
-        if (bForceRelease || nCount < 2) {
-            delete ptData->m_Obj;
-            ptData->m_Obj = NULL;
-        }
-    }
     pos = m_FontMap.GetStartPosition();
     while (pos) {
         CPDF_Dictionary* fontDict;
@@ -233,6 +222,18 @@ void CPDF_DocPageData::Clear(FX_BOOL bForceRelease)
             m_FontFileMap.RemoveKey(ftKey);
         }
     }
+    pos = m_PatternMap.GetStartPosition();
+    while (pos) {
+        CPDF_Object* ptObj;
+        CPDF_CountedObject<CPDF_Pattern*>* ptData;
+        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;
+        }
+    }
 }
 CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly)
 {