diff options
author | dsinclair <dsinclair@chromium.org> | 2016-07-27 07:40:05 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-27 07:40:06 -0700 |
commit | 461eeafe191068ac8c32f2717907fc6a22a667d2 (patch) | |
tree | 25ec06f69550c6daeed66687d4d00fef1d4db4f4 /fpdfsdk/fsdk_mgr.cpp | |
parent | c279a3e1bd3da4e7f7504e438e6df8b7079027f9 (diff) | |
download | pdfium-461eeafe191068ac8c32f2717907fc6a22a667d2.tar.xz |
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
Diffstat (limited to 'fpdfsdk/fsdk_mgr.cpp')
-rw-r--r-- | fpdfsdk/fsdk_mgr.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index 68143d2bdd..8587de1e80 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -263,7 +263,7 @@ CPDFSDK_Document::~CPDFSDK_Document() { CPDFSDK_PageView* CPDFSDK_Document::GetPageView( UnderlyingPageType* pUnderlyingPage, - FX_BOOL ReNew) { + bool ReNew) { auto it = m_pageMap.find(pUnderlyingPage); if (it != m_pageMap.end()) return it->second; @@ -281,7 +281,7 @@ CPDFSDK_PageView* CPDFSDK_Document::GetPageView( CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() { UnderlyingPageType* pPage = UnderlyingFromFPDFPage(m_pEnv->FFI_GetCurrentPage(m_pDoc)); - return pPage ? GetPageView(pPage, TRUE) : nullptr; + return pPage ? GetPageView(pPage, true) : nullptr; } CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { @@ -353,9 +353,12 @@ void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { if (pPageView->IsLocked()) return; + // Remove the page from the map to make sure we don't accidentally attempt + // to use the |pPageView| while we're cleaning it up. + m_pageMap.erase(it); + pPageView->KillFocusAnnotIfNeeded(); delete pPageView; - m_pageMap.erase(it); } UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { |