mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:51:44 +08:00
[events] Fix race condition and missing unlock of mutex (#2453)
This commit is contained in:
parent
d7a8406640
commit
c11c32940e
@ -69,6 +69,7 @@ func (e *Events) OffAll() {
|
||||
for eventName := range e.listeners {
|
||||
delete(e.listeners, eventName)
|
||||
}
|
||||
e.notifyLock.Unlock()
|
||||
}
|
||||
|
||||
// NewEvents creates a new log subsystem
|
||||
@ -115,6 +116,8 @@ func (e *Events) unRegisterListener(eventName string) {
|
||||
|
||||
// Notify backend for the given event name
|
||||
func (e *Events) notifyBackend(eventName string, data ...interface{}) {
|
||||
e.notifyLock.Lock()
|
||||
defer e.notifyLock.Unlock()
|
||||
|
||||
// Get list of event listeners
|
||||
listeners := e.listeners[eventName]
|
||||
@ -123,9 +126,6 @@ func (e *Events) notifyBackend(eventName string, data ...interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
// Lock the listeners
|
||||
e.notifyLock.Lock()
|
||||
|
||||
// We have a dirty flag to indicate that there are items to delete
|
||||
itemsToDelete := false
|
||||
|
||||
@ -163,9 +163,6 @@ func (e *Events) notifyBackend(eventName string, data ...interface{}) {
|
||||
delete(e.listeners, eventName)
|
||||
}
|
||||
}
|
||||
|
||||
// Unlock
|
||||
e.notifyLock.Unlock()
|
||||
}
|
||||
|
||||
func (e *Events) AddFrontend(appFrontend frontend.Frontend) {
|
||||
|
@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fixed `undo`/`redo` on macOS. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2430)
|
||||
- Fixed `Events*` runtime functions in JavaScript not returning the function to cancel the watcher. Fixed by @zllovesuki in [PR](https://github.com/wailsapp/wails/pull/2434)
|
||||
- Fixed AppOptions merging defaults when a custom logger is used. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2452)
|
||||
- Fixed race condition and missing unlock of mutex in events handling. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2453)
|
||||
|
||||
## v2.3.0 - 2022-12-29
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user