Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
widgets: lock access to WidgetWatchers internal map
The WidgetWatchers struct is designed to be embedded into custom widgets in order to satisfy the WidgetWatcher interface. The implementation uses an internal map for storing EventHandlers, but does not lock access to the access of the map within each method. A race condition can occur if Watch, Unwatch, or any event is Posted from separate goroutines. Lock access to the internal map. When posting an event, create a deep copy of the map for iterating. This prevents potential deadlocks from a widget calling Unwatch while handling an event.
- Loading branch information
1 parent
b9dc8a6
commit dbd182b
Showing
1 changed file
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters