Do not re-create the page view when accessing from Document::removeField.

When removing a field from the document we can force the recreation of a
CPDFSDK_PageView by passing |true| as the last parameter to |GetPageView|. This
will force a new page view to be created so we can delete a field from it and,
we then end up with a dangling PageView.

This CL passes |false| to |GetPageView| and skips removing the widget if we
do not receive a pageView back from the document.

BUG=chromium:644219

Review-Url: https://codereview.chromium.org/2312023004
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index c1381f5..d8e3622 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -463,7 +463,7 @@
 
 // removes the specified field from the document.
 // comment:
-// note: if the filed name is not retional, adobe is dumb for it.
+// note: if the filed name is not rational, adobe is dumb for it.
 
 FX_BOOL Document::removeField(IJS_Context* cc,
                               const std::vector<CJS_Value>& params,
@@ -500,9 +500,14 @@
     UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
     ASSERT(pPage);
 
-    CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, true);
-    pPageView->DeleteAnnot(pWidget);
-    pPageView->UpdateRects(aRefresh);
+    // If there is currently no pageview associated with the page being used
+    // do not create one. We may be in the process of tearing down the document
+    // and creating a new pageview at this point will cause bad things.
+    CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, false);
+    if (pPageView) {
+      pPageView->DeleteAnnot(pWidget);
+      pPageView->UpdateRects(aRefresh);
+    }
   }
   m_pDocument->SetChangeMark();