diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-07 09:02:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-07 09:02:48 -0700 |
commit | cb92dc762d5c35232af9f6051b04e9716247d4ae (patch) | |
tree | 2968688106a25b0ef244e021ad569284f07b6296 /testing/embedder_test.cpp | |
parent | ce04a458828b45035dab46c13e14a1f0ae67a2b7 (diff) | |
download | pdfium-cb92dc762d5c35232af9f6051b04e9716247d4ae.tar.xz |
Cleanup page when unloading in embedder tests
When unloading a page in the embedder tests we need to cleanup the internal
page map so if we load the page a second time we don't get a previously unloaded
page.
Review-Url: https://codereview.chromium.org/2322523002
Diffstat (limited to 'testing/embedder_test.cpp')
-rw-r--r-- | testing/embedder_test.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index e10e2a81e8..1ce0f36a45 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -255,6 +255,7 @@ FPDF_PAGE EmbedderTest::LoadPage(int page_number) { FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_OPEN); // Cache the page. page_map_[page_number] = page; + page_reverse_map_[page] = page_number; return page; } @@ -274,6 +275,13 @@ void EmbedderTest::UnloadPage(FPDF_PAGE page) { FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_CLOSE); FORM_OnBeforeClosePage(page, form_handle_); FPDF_ClosePage(page); + + auto it = page_reverse_map_.find(page); + if (it == page_reverse_map_.end()) + return; + + page_map_.erase(it->second); + page_reverse_map_.erase(it); } FPDF_PAGE EmbedderTest::Delegate::GetPage(FPDF_FORMFILLINFO* info, |