From 34da4f056a881c940b1394423fa3b6f5cbcdd774 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 3 Jul 2021 18:34:24 +1000 Subject: [PATCH] =?UTF-8?q?[mac]=20Fix=20onTrayMenuOpen=20by=20being=20les?= =?UTF-8?q?s=20aggressive=20with=20freeing=20memory=20=F0=9F=98=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2/internal/ffenestri/traymenu_darwin.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/v2/internal/ffenestri/traymenu_darwin.c b/v2/internal/ffenestri/traymenu_darwin.c index 32fad5ef..1854d838 100644 --- a/v2/internal/ffenestri/traymenu_darwin.c +++ b/v2/internal/ffenestri/traymenu_darwin.c @@ -140,7 +140,6 @@ void ShowTrayMenu(TrayMenu* trayMenu) { // Create delegate id trayMenuDelegate = msg_reg((id)trayMenuDelegateClass, s("new")); - msg_reg(trayMenuDelegate, s("autorelease")); msg_id(menu, s("setDelegate:"), trayMenuDelegate); objc_setAssociatedObject(trayMenuDelegate, "menu", menu, OBJC_ASSOCIATION_ASSIGN); @@ -156,6 +155,10 @@ void UpdateTrayMenuInPlace(TrayMenu* currentMenu, TrayMenu* newMenu) { // Delete the old menu DeleteMenu(currentMenu->menu); + if( currentMenu->delegate != NULL ) { + msg_reg(currentMenu->delegate, s("release")); + currentMenu->delegate = NULL; + } // Set the new one currentMenu->menu = newMenu->menu; @@ -179,6 +182,10 @@ void DeleteTrayMenu(TrayMenu* trayMenu) { // Delete the menu DeleteMenu(trayMenu->menu); + if( trayMenu->delegate != NULL ) { + msg_reg(trayMenu->delegate, s("release")); + trayMenu->delegate = NULL; + } // Free JSON if (trayMenu->processedJSON != NULL ) { @@ -200,6 +207,10 @@ void DeleteTrayMenuKeepStatusBarItem(TrayMenu* trayMenu) { // Delete the menu DeleteMenu(trayMenu->menu); + if( trayMenu->delegate != NULL ) { + msg_reg(trayMenu->delegate, s("release")); + trayMenu->delegate = NULL; + } // Free JSON if (trayMenu->processedJSON != NULL ) {