Fix for lights not updating after token move #3981
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
Fixes #3979
Description of the Change
In PR #3952, I modifed the
ZoneView.flush()
to run on the Swing thread viaSwingUtilites.invokeLater()
. This kept theZoneView
consistent with itself, but other components assumed they could update theZoneRenderer
immediately after the call toflush()
was done. By delaying the call usinginvokeLater()
, theZoneRenderer
would sometime update prior to theZoneView
flush being run, causing old state to be rendered until another update.This PR goes a step further towards guaranteeing that
ZoneView.flush()
is only called on the Swing thread.ClientMessageHandler
andServerMessageHandler
have been updated to run their message handlers on the Swing thread if they are responsible for updating the model or theZoneRenderer
. This removes the common cases of the ZoneView being accessed off-thread. With that, we no longer useSwingUtilities.invokeLater()
inside of theZoneView.flush()
methods.There might still be other places where off-thread access could happen (e.g., app actions run on a background thread). but a complete solution to threading is beyond this PR.
Possible Drawbacks
Other timing assumptions might be violated somewhere.
Documentation Notes
N/A
Release Notes
N/A
This change is