diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-07 09:55:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-07 09:55:37 -0700 |
commit | 1df1efa3921841fb5fc7fc15e8112eed4375de9f (patch) | |
tree | 9341f9698575b1451b88e1d826f10212db2d7eaf /fpdfsdk/javascript/Field.cpp | |
parent | 85a65b310924eacbd2e720162cc7547153b03077 (diff) | |
download | pdfium-1df1efa3921841fb5fc7fc15e8112eed4375de9f.tar.xz |
Fixup CPDFSDK_PageView and CPDF_Page interactions.
There are several issues when CPDFSDK_PageView and CPDF_Page interact,
especially around deletion. This Cl fixes up several places where things
go wrong working with these objects.
BUG=chromium:632709
Review-Url: https://codereview.chromium.org/2319663002
Diffstat (limited to 'fpdfsdk/javascript/Field.cpp')
-rw-r--r-- | fpdfsdk/javascript/Field.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 3f5e5e1b0f..64c7735dcf 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -260,11 +260,12 @@ void Field::UpdateFormField(CPDFSDK_Document* pDocument, FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh) { - std::vector<CPDFSDK_Widget*> widgets; CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); - pInterForm->GetWidgets(pFormField, &widgets); if (bResetAP) { + std::vector<CPDFSDK_Widget*> widgets; + pInterForm->GetWidgets(pFormField, &widgets); + int nFieldType = pFormField->GetFieldType(); if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { for (CPDFSDK_Annot* pAnnot : widgets) { @@ -285,6 +286,12 @@ void Field::UpdateFormField(CPDFSDK_Document* pDocument, } if (bRefresh) { + // Refresh the widget list. The calls in |bResetAP| may have caused widgets + // to be removed from the list. We need to call |GetWidgets| again to be + // sure none of the widgets have been deleted. + std::vector<CPDFSDK_Widget*> widgets; + pInterForm->GetWidgets(pFormField, &widgets); + for (CPDFSDK_Widget* pWidget : widgets) { CPDFSDK_Document* pDoc = pWidget->GetInterForm()->GetDocument(); pDoc->UpdateAllViews(nullptr, pWidget); |