Skip to content

Commit

Permalink
fix: failsafe JavaScript event emitter notifyListeners (#3695)
Browse files Browse the repository at this point in the history
* fix: failsafe JavaScript event emitter `notifyListeners`

* chore: update change log
  • Loading branch information
mrf345 authored Aug 20, 2024
1 parent 868931f commit 4b6a8e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions v2/internal/frontend/runtime/desktop/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ function notifyListeners(eventData) {
// Get the event name
let eventName = eventData.name;

// Check if we have any listeners for this event
if (eventListeners[eventName]) {
// Keep a list of listener indexes to destroy
const newEventListenerList = eventListeners[eventName]?.slice() || [];

// Keep a list of listener indexes to destroy
const newEventListenerList = eventListeners[eventName].slice();
// Check if we have any listeners for this event
if (newEventListenerList.length) {

// Iterate listeners
for (let count = eventListeners[eventName].length - 1; count >= 0; count -= 1) {
for (let count = newEventListenerList.length - 1; count >= 0; count -= 1) {

// Get next listener
const listener = eventListeners[eventName][count];
const listener = newEventListenerList[count];

let data = eventData.data;

Expand Down
8 changes: 4 additions & 4 deletions v2/internal/frontend/runtime/runtime_debug_desktop.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+ Modified `ZoomFactor` and `IsZoomControlEnabled` options to be Windows-only options in PR[#3644](https://github.com/wailsapp/wails/pull/3644) by @levinit
- Added nil check for Drag-n-Drop on Windows. Fixed by in [PR](https://github.com/wailsapp/wails/pull/3597) by @leaanthony based on the suggestion by @Alpa-1 in [#3596](https://github.com/wailsapp/wails/issues/3596).
- Fixed typos in various .mdx files. [PR #3628](https://github.com/wailsapp/wails/pull/3628) by [@deining](https://github.com/deining)
- Fixed `notifyListeners()` race condition when terminated mid-emission [PR](https://github.com/wailsapp/wails/pull/3695) by [@mrf345](https://github.com/mrf345)

## v2.9.1 - 2024-06-18

Expand Down

0 comments on commit 4b6a8e1

Please sign in to comment.