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

Side by Side Diff: fpdfsdk/fsdk_mgr.cpp

Issue 2320253002: Fix CPDFSDK_PageView cleanup. (Closed)
Patch Set: Created 4 years, 3 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 return pAnnot; 1034 return pAnnot;
1029 } 1035 }
1030 return nullptr; 1036 return nullptr;
1031 } 1037 }
1032 1038
1033 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { 1039 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const {
1034 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; 1040 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict;
1035 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); 1041 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
1036 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; 1042 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1;
1037 } 1043 }
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