Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: fpdfsdk/javascript/Field.cpp

Issue 2340523002: [Merge to 54] Fixup CPDFSDK_PageView and CPDF_Page interactions. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« fpdfsdk/include/fsdk_mgr.h ('K') | « fpdfsdk/include/fsdk_mgr.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/javascript/Field.cpp
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 5c279d6b53a9839a077efca1d18e66f045f9b531..0a184d8ef1307998814e15e698f824ce0c0085ac 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_Widget* pWidget : widgets) {
@@ -284,6 +285,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);
« fpdfsdk/include/fsdk_mgr.h ('K') | « fpdfsdk/include/fsdk_mgr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698