From 44b602876fb16164f6fe88084c89f22ab07b6737 Mon Sep 17 00:00:00 2001 From: koekeishiya Date: Thu, 11 Jul 2019 16:12:11 +0200 Subject: [PATCH] #108 cleanup --- src/misc/notify.h | 18 +++++++++--------- src/osax/sa.m | 4 ++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/misc/notify.h b/src/misc/notify.h index c5372087..1c3028da 100644 --- a/src/misc/notify.h +++ b/src/misc/notify.h @@ -1,6 +1,9 @@ #import #import +static bool g_notify_init; +static NSImage *g_notify_img; + @implementation NSBundle(swizzle) - (NSString *)fake_bundleIdentifier { @@ -12,9 +15,6 @@ } @end -static bool g_notify_init; -static NSImage *g_notify_img; - static bool notify_init(void) { Class c = objc_getClass("NSBundle"); @@ -29,18 +29,18 @@ static bool notify_init(void) static void notify(char *message, char *subtitle) { + @autoreleasepool { + if (!g_notify_init) notify_init(); NSUserNotification *notification = [[NSUserNotification alloc] init]; notification.title = @"yabai"; notification.subtitle = subtitle ? [NSString stringWithUTF8String:subtitle] : NULL; notification.informativeText = message ? [NSString stringWithUTF8String:message] : NULL; - - if (g_notify_img) { - [notification setValue:g_notify_img forKey:@"_identityImage"]; - [notification setValue:@(false) forKey:@"_identityImageHasBorder"]; - } - + [notification setValue:g_notify_img forKey:@"_identityImage"]; + [notification setValue:@(false) forKey:@"_identityImageHasBorder"]; [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; [notification release]; + + } } diff --git a/src/osax/sa.m b/src/osax/sa.m index 6aa4e5d3..7f2872ef 100644 --- a/src/osax/sa.m +++ b/src/osax/sa.m @@ -296,6 +296,8 @@ int scripting_addition_uninstall(void) int scripting_addition_load(void) { + @autoreleasepool { + if (!scripting_addition_is_installed()) return 1; SALoader *loader = [[SALoader alloc] init]; @@ -359,4 +361,6 @@ int scripting_addition_load(void) warn("yabai: scripting-addition either failed to load or could not inject payload into Dock.app due to unknown error: %d\n", loader->result); return 1; } + + } }