| Index: fpdfsdk/javascript/Field.cpp
|
| diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
|
| index 3f5e5e1b0f57ae9aabb2675b4a0705d8e1bee752..64c7735dcf7f989e142bec1e611ea68db4bcf075 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);
|
|
|