From 461eeafe191068ac8c32f2717907fc6a22a667d2 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 27 Jul 2016 07:40:05 -0700 Subject: Reland of Remove pageview from map immediately This reverts commit f2cee9894b9f7cf2e50060965ad1eedd90ab55b6. This CL removes the default parameter from the CPDFSDK_Document::GetPageView |ReNew| flag and updates the code as needed. In CFFL_FormFillter::KillFocusForAnnot we flip the flag to |FALSE| as we don't want to re-create the page view if it is already removed. If we don't do this then the page view will be re-created in the map, the page associated to the page view, but then the page can be deleted out from under the pageview as it isn't owned by the page view. BUG=chromium:630654 Review-Url: https://codereview.chromium.org/2179163004 --- fpdfsdk/formfiller/cffl_formfiller.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/formfiller/cffl_formfiller.cpp') diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index d7bc9586a4..479a1bc169 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -220,7 +220,7 @@ FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags) { if (IsValid()) { - CPDFSDK_PageView* pPageView = GetCurPageView(); + CPDFSDK_PageView* pPageView = GetCurPageView(true); ASSERT(pPageView); if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { @@ -235,7 +235,7 @@ FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) { if (IsValid()) { - CPDFSDK_PageView* pPageView = GetCurPageView(); + CPDFSDK_PageView* pPageView = GetCurPageView(true); ASSERT(pPageView); if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { @@ -250,7 +250,7 @@ void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); - CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage); + CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage, true); if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) pWnd->SetFocus(); @@ -263,7 +263,7 @@ void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { if (!IsValid()) return; - CPDFSDK_PageView* pPageView = GetCurPageView(); + CPDFSDK_PageView* pPageView = GetCurPageView(false); if (!pPageView) return; @@ -456,10 +456,10 @@ CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const { return CFX_FloatRect(0, 0, fWidth, fHeight); } -CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() { +CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) { UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage(); CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); - return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr; + return pSDKDoc ? pSDKDoc->GetPageView(pPage, renew) : nullptr; } CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { -- cgit v1.2.3