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

Post timer_(name)_tick event on restart when already running #1626

Merged

Conversation

avanwinkle
Copy link
Collaborator

@avanwinkle avanwinkle commented Jan 6, 2022

This PR fixes a bug in Timers' restart behavior.

The restart() method calls reset() and start(), but if the Timer is already running then the start method exits immediately. There is a bug here because the start method is meant to post the timer_name_tick event, but the early exit prevents that code path. As a result, calling restart() on a stopped Timer will post the timer_name_tick event but calling restart() on a running Timer will not post the event, and it will be another full tick before any listeners know that the timer tick has changed.

This PR tweaks the restart() behavior to only call start() the timer is not running, and otherwise post the event directly. For safety, an instance elsewhere of calling reset() then start() was replaced with a call to restart().

Also, a test!

timey wimey

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@avanwinkle avanwinkle merged commit 8e6b74c into missionpinball:dev Jan 8, 2022
@avanwinkle avanwinkle deleted the timer-tick-event-on-restart branch December 4, 2023 23:32
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.

1 participant