summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfview.cpp')
-rw-r--r--fpdfsdk/fpdfview.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index dee71ac9e2..1c0af1dc10 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -673,9 +673,20 @@ DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) {
#else // PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView =
static_cast<CPDFSDK_PageView*>(pPage->GetView());
- if (pPageView && pPageView->IsLocked()) {
- pPageView->TakeOverPage();
- return;
+ if (pPageView) {
+ if (pPageView->IsLocked()) {
+ pPageView->TakePageOwnership();
+ return;
+ }
+
+ bool owned = pPageView->OwnsPage();
+ // This will delete the |pPageView| object. We must cleanup the PageView
+ // first because it will attempt to reset the View on the |pPage| during
+ // destruction.
+ pPageView->GetSDKDocument()->RemovePageView(pPage);
+ // If the page was owned then the pageview will have deleted the page.
+ if (owned)
+ return;
}
delete pPage;
#endif // PDF_ENABLE_XFA