Skip to content

Reset step advance condition state on every step advance#887

Open
devnull133 wants to merge 1 commit into
stadiamaps:mainfrom
devnull133:fix/reset-condition-state-on-step-advance
Open

Reset step advance condition state on every step advance#887
devnull133 wants to merge 1 commit into
stadiamaps:mainfrom
devnull133:fix/reset-condition-state-on-step-advance

Conversation

@devnull133
Copy link
Copy Markdown
Contributor

Hi, I noticed this while working on something else. I'm not sure how often the manual step advance is used, but it feels like it should be fixed anyway.

NavigationController::advance_to_next_step carried the existing step advance condition forward unchanged. Auto-advance was unaffected because should_advance_step already returns a fresh condition via advance_to_new_instance, but manual advance - Navigator::advance_to_next_step bypasses that path entirely. Stateful conditions (the entry-latch family, composites containing them, custom user implementations) leaked their per-step state into the next step.

`NavigationController::advance_to_next_step` carried the existing step
advance condition forward unchanged. Auto-advance was unaffected because
`should_advance_step` already returns a fresh condition via
`advance_to_new_instance`, but manual advance — `Navigator::advance_to_next_step`
called directly, e.g. from platform code wrapping a ManualStepCondition or
walking out of GPS coverage — bypasses that path entirely. Stateful
conditions (the entry-latch family, composites containing them, custom
user implementations) leaked their per-step state into the next step.

Call `new_instance()` on the carried condition so both advance paths
honor the trait's documented reset contract.
Copy link
Copy Markdown
Collaborator

@Archdoog Archdoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This looks good as it, thanks 👍

A note/question. Any thoughts on any further cleanup?

E.g. we could extract new instance out to the NavigationController so that anytime we "recycle" a continuing or advanced condition it's clear at the call site. The way I built this, where the new_instance was hidden inside the conditional logic on some conditions is definitely confusing looking from the top down. Even though it made sense from the state management process inside each one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants