From 6d3be6670c1f8c7c36f84a0253d08852d361fbd0 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 7 Aug 2026 03:15:47 +0000 Subject: [PATCH 06/38] version (Apple): use non-ARC-only plist loading and NSAutoreleasePool guard Ported from https://github.com/macos-powerpc/powerpc-ports/blob/main/sysutils/fastfetch/files/0013-wm_apple-unbreak.patch --- src/common/apple/version.m | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/common/apple/version.m b/src/common/apple/version.m index e6d4fae62..cf9bfda42 100644 --- a/src/common/apple/version.m +++ b/src/common/apple/version.m @@ -1,7 +1,16 @@ #include "common/apple/version.h" #include "common/strutil.h" -#import +#include +#include + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +#define POOLSTART NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#define POOLEND [pool release]; +#else +#define POOLSTART +#define POOLEND +#endif #define APP_CONTENTS_MACOS ".app/Contents/MacOS" @@ -18,26 +27,30 @@ bool ffGetAppNameAndVersion(const char* exePath, FFstrbuf* retName, FFstrbuf* re char infoPlistPath[PATH_MAX]; memcpy(infoPlistPath, exePath, (size_t) (lastSlash - exePath)); memcpy(infoPlistPath + (lastSlash - exePath), "Info.plist", sizeof("Info.plist")); // X.app/Contents/Info.plist - NSError* error; - NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@(infoPlistPath)] - error:&error]; + + POOLSTART + NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithUTF8String:infoPlistPath]]; if (!dict) { + POOLEND return false; } if (retName) { - NSString* bundleName = dict[@"CFBundleDisplayName"] ?: dict[@"CFBundleName"]; + NSString* bundleName = [dict objectForKey:@"CFBundleDisplayName"]; + if (!bundleName) bundleName = [dict objectForKey:@"CFBundleName"]; + if (bundleName) { - ffStrbufSetS(retName, bundleName.UTF8String); + ffStrbufSetS(retName, [bundleName UTF8String]); } } if (retVersion) { - NSString* bundleVersion = dict[@"CFBundleShortVersionString"]; + NSString* bundleVersion = [dict objectForKey:@"CFBundleShortVersionString"]; if (bundleVersion) { - ffStrbufSetS(retVersion, bundleVersion.UTF8String); + ffStrbufSetS(retVersion, [bundleVersion UTF8String]); } } + POOLEND return true; } -- 2.43.0