OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |