mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 15:11:53 +08:00
fix: failsafe JavaScript event emitter notifyListeners
(#3695)
* fix: failsafe JavaScript event emitter `notifyListeners` * chore: update change log
This commit is contained in:
parent
868931fe72
commit
4b6a8e17c5
@ -90,17 +90,17 @@ function notifyListeners(eventData) {
|
|||||||
// Get the event name
|
// Get the event name
|
||||||
let eventName = eventData.name;
|
let eventName = eventData.name;
|
||||||
|
|
||||||
// Check if we have any listeners for this event
|
// Keep a list of listener indexes to destroy
|
||||||
if (eventListeners[eventName]) {
|
const newEventListenerList = eventListeners[eventName]?.slice() || [];
|
||||||
|
|
||||||
// Keep a list of listener indexes to destroy
|
// Check if we have any listeners for this event
|
||||||
const newEventListenerList = eventListeners[eventName].slice();
|
if (newEventListenerList.length) {
|
||||||
|
|
||||||
// Iterate listeners
|
// 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
|
// Get next listener
|
||||||
const listener = eventListeners[eventName][count];
|
const listener = newEventListenerList[count];
|
||||||
|
|
||||||
let data = eventData.data;
|
let data = eventData.data;
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@
|
|||||||
}
|
}
|
||||||
function notifyListeners(eventData) {
|
function notifyListeners(eventData) {
|
||||||
let eventName = eventData.name;
|
let eventName = eventData.name;
|
||||||
if (eventListeners[eventName]) {
|
const newEventListenerList = eventListeners[eventName]?.slice() || [];
|
||||||
const newEventListenerList = eventListeners[eventName].slice();
|
if (newEventListenerList.length) {
|
||||||
for (let count = eventListeners[eventName].length - 1; count >= 0; count -= 1) {
|
for (let count = newEventListenerList.length - 1; count >= 0; count -= 1) {
|
||||||
const listener = eventListeners[eventName][count];
|
const listener = newEventListenerList[count];
|
||||||
let data = eventData.data;
|
let data = eventData.data;
|
||||||
const destroy = listener.Callback(data);
|
const destroy = listener.Callback(data);
|
||||||
if (destroy) {
|
if (destroy) {
|
||||||
|
@ -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
|
+ 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).
|
- 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 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
|
## v2.9.1 - 2024-06-18
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user