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

Side by Side Diff: fpdfsdk/fsdk_mgr.cpp

Issue 2179283005: Remove pageview from map immediately (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/include/fsdk_mgr.h" 7 #include "fpdfsdk/include/fsdk_mgr.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { 347 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) {
348 auto it = m_pageMap.find(pUnderlyingPage); 348 auto it = m_pageMap.find(pUnderlyingPage);
349 if (it == m_pageMap.end()) 349 if (it == m_pageMap.end())
350 return; 350 return;
351 351
352 CPDFSDK_PageView* pPageView = it->second; 352 CPDFSDK_PageView* pPageView = it->second;
353 if (pPageView->IsLocked()) 353 if (pPageView->IsLocked())
354 return; 354 return;
355 355
356 // Remove the page from the map to make sure we don't accidentally attempt
357 // to use the |pPageView| while we're cleaning it up.
358 m_pageMap.erase(it);
359
356 pPageView->KillFocusAnnotIfNeeded(); 360 pPageView->KillFocusAnnotIfNeeded();
357 delete pPageView; 361 delete pPageView;
358 m_pageMap.erase(it);
359 } 362 }
360 363
361 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { 364 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) {
362 return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); 365 return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex));
363 } 366 }
364 367
365 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { 368 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() {
366 if (!m_pInterForm) 369 if (!m_pInterForm)
367 m_pInterForm.reset(new CPDFSDK_InterForm(this)); 370 m_pInterForm.reset(new CPDFSDK_InterForm(this));
368 return m_pInterForm.get(); 371 return m_pInterForm.get();
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { 1046 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const {
1044 #ifdef PDF_ENABLE_XFA 1047 #ifdef PDF_ENABLE_XFA
1045 CPDF_Page* pPage = m_page->GetPDFPage(); 1048 CPDF_Page* pPage = m_page->GetPDFPage();
1046 #else // PDF_ENABLE_XFA 1049 #else // PDF_ENABLE_XFA
1047 CPDF_Page* pPage = m_page; 1050 CPDF_Page* pPage = m_page;
1048 #endif // PDF_ENABLE_XFA 1051 #endif // PDF_ENABLE_XFA
1049 CPDF_Dictionary* pDict = pPage->m_pFormDict; 1052 CPDF_Dictionary* pDict = pPage->m_pFormDict;
1050 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); 1053 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
1051 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; 1054 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1;
1052 } 1055 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698