fix(info): fix segmentation fault on macOS
This commit is contained in:
parent
8c2e02030a
commit
fc69b7a79f
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
int32_t info_get_title(char *buffer, int32_t buffer_size)
|
int32_t info_get_title(char *buffer, int32_t buffer_size)
|
||||||
{
|
{
|
||||||
|
@autoreleasepool {
|
||||||
CFArrayRef windows = CGWindowListCopyWindowInfo(kCGWindowListExcludeDesktopElements | kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
CFArrayRef windows = CGWindowListCopyWindowInfo(kCGWindowListExcludeDesktopElements | kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
|
|
||||||
|
@ -45,32 +46,33 @@ int32_t info_get_title(char *buffer, int32_t buffer_size)
|
||||||
|
|
||||||
CFRelease(windows);
|
CFRelease(windows);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t info_get_exec(char *buffer, int32_t buffer_size)
|
int32_t info_get_exec(char *buffer, int32_t buffer_size)
|
||||||
{
|
{
|
||||||
|
@autoreleasepool {
|
||||||
NSRunningApplication *frontApp = [[NSWorkspace sharedWorkspace] frontmostApplication];
|
NSRunningApplication *frontApp = [[NSWorkspace sharedWorkspace] frontmostApplication];
|
||||||
NSString *bundlePath = [frontApp bundleURL].path;
|
NSString *bundlePath = [frontApp bundleURL].path;
|
||||||
const char * path = [bundlePath UTF8String];
|
const char * path = [bundlePath UTF8String];
|
||||||
|
|
||||||
snprintf(buffer, buffer_size, "%s", path);
|
snprintf(buffer, buffer_size, "%s", path);
|
||||||
|
}
|
||||||
[bundlePath release];
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t info_get_class(char *buffer, int32_t buffer_size)
|
int32_t info_get_class(char *buffer, int32_t buffer_size)
|
||||||
{
|
{
|
||||||
|
@autoreleasepool {
|
||||||
NSRunningApplication *frontApp = [[NSWorkspace sharedWorkspace] frontmostApplication];
|
NSRunningApplication *frontApp = [[NSWorkspace sharedWorkspace] frontmostApplication];
|
||||||
NSString *bundleId = frontApp.bundleIdentifier;
|
NSString *bundleId = frontApp.bundleIdentifier;
|
||||||
const char * bundle = [bundleId UTF8String];
|
const char * bundle = [bundleId UTF8String];
|
||||||
|
|
||||||
snprintf(buffer, buffer_size, "%s", bundle);
|
snprintf(buffer, buffer_size, "%s", bundle);
|
||||||
|
}
|
||||||
[bundleId release];
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user