| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 354 |
| 355 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { | 355 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { |
| 356 auto it = m_pageMap.find(pUnderlyingPage); | 356 auto it = m_pageMap.find(pUnderlyingPage); |
| 357 if (it == m_pageMap.end()) | 357 if (it == m_pageMap.end()) |
| 358 return; | 358 return; |
| 359 | 359 |
| 360 CPDFSDK_PageView* pPageView = it->second; | 360 CPDFSDK_PageView* pPageView = it->second; |
| 361 if (pPageView->IsLocked()) | 361 if (pPageView->IsLocked()) |
| 362 return; | 362 return; |
| 363 | 363 |
| 364 // This must happen before we remove |pPageView| from the map because |
| 365 // |KillFocusAnnotIfNeeded| can call into the |GetPage| method which will |
| 366 // look for this page view in the map, if it doesn't find it a new one will |
| 367 // be created. We then have two page views pointing to the same page and |
| 368 // bad things happen. |
| 369 pPageView->KillFocusAnnotIfNeeded(); |
| 370 |
| 364 // Remove the page from the map to make sure we don't accidentally attempt | 371 // Remove the page from the map to make sure we don't accidentally attempt |
| 365 // to use the |pPageView| while we're cleaning it up. | 372 // to use the |pPageView| while we're cleaning it up. |
| 366 m_pageMap.erase(it); | 373 m_pageMap.erase(it); |
| 367 | 374 |
| 368 pPageView->KillFocusAnnotIfNeeded(); | |
| 369 delete pPageView; | 375 delete pPageView; |
| 370 } | 376 } |
| 371 | 377 |
| 372 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { | 378 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { |
| 373 return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); | 379 return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); |
| 374 } | 380 } |
| 375 | 381 |
| 376 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { | 382 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { |
| 377 if (!m_pInterForm) | 383 if (!m_pInterForm) |
| 378 m_pInterForm.reset(new CPDFSDK_InterForm(this)); | 384 m_pInterForm.reset(new CPDFSDK_InterForm(this)); |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 1054 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
| 1049 #ifdef PDF_ENABLE_XFA | 1055 #ifdef PDF_ENABLE_XFA |
| 1050 CPDF_Page* pPage = m_page->GetPDFPage(); | 1056 CPDF_Page* pPage = m_page->GetPDFPage(); |
| 1051 #else // PDF_ENABLE_XFA | 1057 #else // PDF_ENABLE_XFA |
| 1052 CPDF_Page* pPage = m_page; | 1058 CPDF_Page* pPage = m_page; |
| 1053 #endif // PDF_ENABLE_XFA | 1059 #endif // PDF_ENABLE_XFA |
| 1054 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 1060 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
| 1055 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 1061 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
| 1056 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 1062 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
| 1057 } | 1063 } |
| OLD | NEW |