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

Unified Diff: fpdfsdk/cpdfsdk_formfillenvironment.cpp

Issue 2489663002: Fix CPDFSDK_FormFillEnvironment destruction order (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « fpdfsdk/cpdfsdk_formfillenvironment.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/cpdfsdk_formfillenvironment.cpp
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 9852bdc9b9cea9c62b094d28aacda25fc51f12f6..8ab3b46a916971d040b727c9f1f749e6129f3adc 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -41,12 +41,14 @@ CPDFSDK_FormFillEnvironment::CPDFSDK_FormFillEnvironment(
CPDFSDK_FormFillEnvironment::~CPDFSDK_FormFillEnvironment() {
m_bBeingDestroyed = true;
-
ClearAllFocusedAnnots();
- // |m_pAnnotHandlerMgr| will try to access |m_pFormFiller|
- // when it cleans up. So, we must make sure it is cleaned up before
- // |m_pFormFiller|.
+ // |m_PageMap| will try to access |m_pInterForm| when it cleans itself up.
+ // Make sure it is deleted before |m_pInterForm|.
+ m_PageMap.clear();
+
+ // |m_pAnnotHandlerMgr| will try to access |m_pFormFiller| when it cleans
+ // itself up. Make sure it is deleted before |m_pFormFiller|.
m_pAnnotHandlerMgr.reset();
// Must destroy the |m_pFormFiller| before the environment (|this|)
@@ -563,7 +565,7 @@ void CPDFSDK_FormFillEnvironment::PageEvent(int iPageCount,
#endif // PDF_ENABLE_XFA
void CPDFSDK_FormFillEnvironment::ClearAllFocusedAnnots() {
- for (auto& it : m_pageMap) {
+ for (auto& it : m_PageMap) {
if (it.second->IsValidSDKAnnot(GetFocusAnnot()))
KillFocusAnnot(0);
}
@@ -572,15 +574,15 @@ void CPDFSDK_FormFillEnvironment::ClearAllFocusedAnnots() {
CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(
UnderlyingPageType* pUnderlyingPage,
bool renew) {
- auto it = m_pageMap.find(pUnderlyingPage);
- if (it != m_pageMap.end())
+ auto it = m_PageMap.find(pUnderlyingPage);
+ if (it != m_PageMap.end())
return it->second.get();
if (!renew)
return nullptr;
CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage);
- m_pageMap[pUnderlyingPage].reset(pPageView);
+ m_PageMap[pUnderlyingPage].reset(pPageView);
// Delay to load all the annotations, to avoid endless loop.
pPageView->LoadFXAnnots();
return pPageView;
@@ -598,8 +600,8 @@ CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(int nIndex) {
if (!pTempPage)
return nullptr;
- auto it = m_pageMap.find(pTempPage);
- return it != m_pageMap.end() ? it->second.get() : nullptr;
+ auto it = m_PageMap.find(pTempPage);
+ return it != m_PageMap.end() ? it->second.get() : nullptr;
}
void CPDFSDK_FormFillEnvironment::ProcJavascriptFun() {
@@ -647,8 +649,8 @@ bool CPDFSDK_FormFillEnvironment::ProcOpenAction() {
void CPDFSDK_FormFillEnvironment::RemovePageView(
UnderlyingPageType* pUnderlyingPage) {
- auto it = m_pageMap.find(pUnderlyingPage);
- if (it == m_pageMap.end())
+ auto it = m_PageMap.find(pUnderlyingPage);
+ if (it == m_PageMap.end())
return;
CPDFSDK_PageView* pPageView = it->second.get();
@@ -669,7 +671,7 @@ void CPDFSDK_FormFillEnvironment::RemovePageView(
// 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);
+ m_PageMap.erase(it);
}
UnderlyingPageType* CPDFSDK_FormFillEnvironment::GetPage(int nIndex) {
@@ -684,7 +686,7 @@ CPDFSDK_InterForm* CPDFSDK_FormFillEnvironment::GetInterForm() {
void CPDFSDK_FormFillEnvironment::UpdateAllViews(CPDFSDK_PageView* pSender,
CPDFSDK_Annot* pAnnot) {
- for (const auto& it : m_pageMap) {
+ for (const auto& it : m_PageMap) {
CPDFSDK_PageView* pPageView = it.second.get();
if (pPageView != pSender)
pPageView->UpdateView(pAnnot);
« no previous file with comments | « fpdfsdk/cpdfsdk_formfillenvironment.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698