Skip to content

Commit

Permalink
Merge pull request getodk#2829 from grzesiek2010/COLLECT-2828
Browse files Browse the repository at this point in the history
Fixed crashes when the user opens form with unexpected element in 'field-list'
  • Loading branch information
yanokwa authored Jan 30, 2019
2 parents 1325a6d + 0f17993 commit 8cd4a31
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public boolean saveAnswer(FormIndex index, IAnswerData data) throws JavaRosaExce
public int stepToNextEvent(boolean stepIntoGroup) {
if ((getEvent() == FormEntryController.EVENT_GROUP
|| getEvent() == FormEntryController.EVENT_REPEAT)
&& indexIsInFieldList() && getQuestionPrompts().length > 0 && !stepIntoGroup) {
&& indexIsInFieldList() && !isGroupEmpty() && !stepIntoGroup) {
return stepOverGroup();
} else {
return formEntryController.stepToNextEvent();
Expand Down Expand Up @@ -902,6 +902,11 @@ public FormEntryPrompt[] getQuestionPrompts() throws RuntimeException {
return questions;
}

private boolean isGroupEmpty() {
GroupDef group = (GroupDef) formEntryController.getModel().getForm().getChild(getFormIndex());
return getIndicesForGroup(group).isEmpty();
}

/**
* Recursively gets all indices contained in this group and its children
*/
Expand Down

0 comments on commit 8cd4a31

Please sign in to comment.