acmerobotics / ftc-dashboard

React-based web dashboard designed for FTC
https://acmerobotics.github.io/ftc-dashboard
Other
171 stars 129 forks source link

Fix dashboard toggle OpMode not checking for stop #63

Closed abidingabi closed 3 years ago

abidingabi commented 3 years ago

If the user stops the Dashboard Enable/Disable OpMode while waitForStart() is running, the current thread gets interrupted. However, interrupting the thread does not halt thread execution, meaning that even if the user hits "stop" during the initialization phase, dashboard's enable state will be toggled. By checking that isStopRequested() is false, this change makes sure that stop has been pressed before toggling dashboard's enable state.

abidingabi commented 3 years ago

Thanks for the fix. Sorry to nit, but I prefer the check to return early like here.

I changed it to use an early return.