From 51c23588614397089a5ce182cddea729f0be6fa0 Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Tue, 1 Oct 2024 08:27:13 +0200 Subject: [PATCH] guard against disposed notifications being shown in the first place --- haxe/ui/notifications/NotificationManager.hx | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/haxe/ui/notifications/NotificationManager.hx b/haxe/ui/notifications/NotificationManager.hx index b6e9b7764..93395cf8a 100644 --- a/haxe/ui/notifications/NotificationManager.hx +++ b/haxe/ui/notifications/NotificationManager.hx @@ -80,14 +80,23 @@ class NotificationManager extends EventDispatcher { var notification = new Notification(); notification.registerEvent(UIEvent.DESTROY, onNotificationDestroyed); notification.notificationData = notificationData; - Timer.delay(function() { + if (notificationDisplayDelayMs <= 0) { if (!_isAnimating) { pushNotification(notification); } else { _addQueue.push(notification); startTimer(); } - }, notificationDisplayDelayMs); + } else { + Timer.delay(function() { + if (!_isAnimating) { + pushNotification(notification); + } else { + _addQueue.push(notification); + startTimer(); + } + }, notificationDisplayDelayMs); + } return notification; } @@ -153,6 +162,10 @@ class NotificationManager extends EventDispatcher { notification.opacity = 0; Screen.instance.addComponent(notification); Toolkit.callLater(function () { + // its possible that in this notification could have been destroyed in this one frame + if (@:privateAccess notification._isDisposed) { + return; + } notification.validateNow(); var scx = Screen.instance.width; var scy = Screen.instance.height; @@ -176,6 +189,10 @@ class NotificationManager extends EventDispatcher { if (notification.notificationData.expiryMs > 0) { Timer.delay(function () { + // its possible that in this notification could have been destroyed in this time + if (@:privateAccess notification._isDisposed) { + return; + } removeNotification(notification); }, notification.notificationData.expiryMs); }