Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: fpdfsdk/src/fsdk_mgr.cpp

Issue 594403003: Lock page in LoadFXAnnot to prevent unintended page closing (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« fpdfsdk/include/fsdk_mgr.h ('K') | « fpdfsdk/src/fpdfview.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fsdk_mgr.cpp
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 52173b4c96a29269489979adb901a4e493a05aec..ddcf8e70a31e5f0333780bc21eb1a7a43809b541 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -332,7 +332,14 @@ CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv
CPDFSDK_Document::~CPDFSDK_Document()
{
- m_pageMap.RemoveAll();
+ FX_POSITION pos = m_pageMap.GetStartPosition();
+ while (pos) {
+ CPDF_Page* pPage = NULL;
+ CPDFSDK_PageView* pPageView = NULL;
+ m_pageMap.GetNextAssoc(pos, pPage, pPageView);
+ delete pPageView;
Tom Sepez 2014/09/23 23:38:54 don't we need to remove the item from the page map
Bo Xu 2014/09/24 00:04:30 delete pPageView is removing the value of the hash
+ }
+ m_pageMap.RemoveAll();
if(m_pInterForm)
{
m_pInterForm->Destroy();
@@ -453,7 +460,7 @@ CPDF_OCContext* CPDFSDK_Document::GetOCContext()
void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage)
{
CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pPDFPage);
- if(pPageView)
+ if(pPageView && !pPageView->IsLocked())
{
delete pPageView;
m_pageMap.RemoveKey(pPDFPage);
@@ -608,20 +615,21 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
pPDFInterForm->FixPageFields(page);
}
-
+ m_page->SetPrivateData((FX_LPVOID)m_page, (FX_LPVOID)this, NULL);
m_fxAnnotArray.RemoveAll();
m_bEnterWidget = FALSE;
m_bExitWidget = FALSE;
m_bOnWidget = FALSE;
m_CaptureWidget = NULL;
- m_bValid = FALSE;
+ m_Flag = 0;
}
CPDFSDK_PageView::~CPDFSDK_PageView()
{
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
int nAnnotCount = m_fxAnnotArray.GetSize();
+
for (int i=0; i<nAnnotCount; i++)
{
CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
@@ -638,6 +646,10 @@ CPDFSDK_PageView::~CPDFSDK_PageView()
delete m_pAnnotList;
m_pAnnotList = NULL;
}
+ m_page->RemovePrivateData((FX_LPVOID)m_page);
+ if(m_Flag & PAGEVIEW_FLAG_TAKEOVERPAGE) {
+ delete m_page;
+ }
}
void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions)
@@ -972,6 +984,7 @@ void CPDFSDK_PageView::LoadFXAnnots()
m_pAnnotList = new CPDF_AnnotList(m_page);
CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
int nCount = m_pAnnotList->Count();
+ SetLock();
for(int i=0; i<nCount; i++)
{
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
@@ -981,6 +994,7 @@ void CPDFSDK_PageView::LoadFXAnnots()
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
ASSERT(pAnnotHandlerMgr != NULL);
+
if(pAnnotHandlerMgr)
{
CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
@@ -992,6 +1006,7 @@ void CPDFSDK_PageView::LoadFXAnnots()
}
}
+ ClearLock();
}
void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects)
« fpdfsdk/include/fsdk_mgr.h ('K') | « fpdfsdk/src/fpdfview.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698