Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use cached choices if the cached list comes from a different repeat #643

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/org/javarosa/core/model/ItemsetBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ItemsetBinding implements Externalizable, Localizable {
// Values needed to determine whether the cached list should be expired (not serialized)
private Map<TreeReference, IAnswerData> cachedTriggerValues;
private Long cachedRandomizeSeed;
private TreeReference cachedRef;

/**
* note that storing both the ref and expr for everything is kind of redundant, but we're forced
Expand Down Expand Up @@ -91,7 +92,8 @@ public List<SelectChoice> getChoices(FormDef formDef, TreeReference curQRef) {

// Return cached list if possible
if (cachedFilteredChoiceList != null && allTriggerRefsBound && Objects.equals(currentTriggerValues, cachedTriggerValues)
&& Objects.equals(currentRandomizeSeed, cachedRandomizeSeed)) {
&& Objects.equals(currentRandomizeSeed, cachedRandomizeSeed)
&& Objects.equals(curQRef, cachedRef)) {
return randomize && cachedRandomizeSeed == null ? shuffle(cachedFilteredChoiceList) : cachedFilteredChoiceList;
}

Expand Down Expand Up @@ -148,6 +150,7 @@ public List<SelectChoice> getChoices(FormDef formDef, TreeReference curQRef) {

cachedTriggerValues = currentTriggerValues;
cachedRandomizeSeed = currentRandomizeSeed;
cachedRef = curQRef;

return cachedFilteredChoiceList;
}
Expand Down