From d3fbbc62318f1d45a5ff0b25c60ee3ea63bee312 Mon Sep 17 00:00:00 2001 From: Peter Fern Date: Thu, 28 Mar 2024 20:08:45 +1100 Subject: [PATCH] fix(popups): Fix goroutine leak in both HUD and Notifications This likely leaks callbacks too, and eventually crashes. --- cmd/hyprpanel-client/hud.go | 5 ++++- cmd/hyprpanel-client/notification_item.go | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/hyprpanel-client/hud.go b/cmd/hyprpanel-client/hud.go index f9bea86..3d1579a 100644 --- a/cmd/hyprpanel-client/hud.go +++ b/cmd/hyprpanel-client/hud.go @@ -229,7 +229,10 @@ func (h *hud) update(data *eventv1.HudNotificationValue) error { h.showNotification() go func() { - <-h.timer.C + select { + case <-h.timer.C: + case <-h.itemClosed: + } h.closeItem() }() diff --git a/cmd/hyprpanel-client/notification_item.go b/cmd/hyprpanel-client/notification_item.go index 438a39a..cc08a7e 100644 --- a/cmd/hyprpanel-client/notification_item.go +++ b/cmd/hyprpanel-client/notification_item.go @@ -312,7 +312,11 @@ func (i *notificationItem) build(container *gtk.Box) error { }) go func() { - <-i.timer.C + select { + case <-i.timer.C: + case <-i.closed: + } + i.close() }()