# HG changeset patch # User Paper # Date 1713482611 14400 # Node ID 22f9aacf6ac1eb791cf1c5db3d96dd0779346750 # Parent f6a756c19bfb70c69b602e6e833de1ee11e49d87 osx: don't dereference NULL pointers fail diff -r f6a756c19bfb -r 22f9aacf6ac1 scripts/osx/deploy_build.sh --- a/scripts/osx/deploy_build.sh Thu Apr 18 17:24:42 2024 -0400 +++ b/scripts/osx/deploy_build.sh Thu Apr 18 19:23:31 2024 -0400 @@ -22,7 +22,7 @@ install_name_tool -change "/usr/local/lib/lib$i.0.dylib" "@executable_path/../Frameworks/lib$i.0.dylib" "$BUNDLE_NAME.app/Contents/MacOS/minori" done -macdeployqt "$BUNDLE_NAME.app" +macdeployqt "$BUNDLE_NAME.app" -no-strip if $FRAMEWORK_MODE; then for i in QtCore QtGui QtWidgets; do install_name_tool -id @executable_path/../Frameworks/$i.framework/Versions/5/$i $BUNDLE_NAME.app/Contents/Frameworks/$i.framework/Versions/5/$i diff -r f6a756c19bfb -r 22f9aacf6ac1 src/core/anime.cc --- a/src/core/anime.cc Thu Apr 18 17:24:42 2024 -0400 +++ b/src/core/anime.cc Thu Apr 18 19:23:31 2024 -0400 @@ -10,6 +10,7 @@ #include #include #include +#include namespace Anime { diff -r f6a756c19bfb -r 22f9aacf6ac1 src/sys/osx/dark_theme.cc --- a/src/sys/osx/dark_theme.cc Thu Apr 18 17:24:42 2024 -0400 +++ b/src/sys/osx/dark_theme.cc Thu Apr 18 19:23:31 2024 -0400 @@ -22,22 +22,27 @@ CFBundleRef appkit_bundle = CFBundleGetBundleWithIdentifier(kAppKitBundleID); if (!appkit_bundle) return false; - - NSAppearanceNameAqua = - *reinterpret_cast(CFBundleGetDataPointerForName(appkit_bundle, CFSTR("NSAppearanceNameAqua"))); - if (!NSAppearanceNameAqua) + + auto aqua_appearance = reinterpret_cast(CFBundleGetDataPointerForName(appkit_bundle, CFSTR("NSAppearanceNameAqua"))); + if (!aqua_appearance) return false; + NSAppearanceNameAqua = *aqua_appearance; - NSAppearanceNameDarkAqua = *reinterpret_cast( + auto dark_aqua_appearance = reinterpret_cast( CFBundleGetDataPointerForName(appkit_bundle, CFSTR("NSAppearanceNameDarkAqua"))); - if (!NSAppearanceNameDarkAqua) + if (!dark_aqua_appearance) return false; + NSAppearanceNameDarkAqua = *dark_aqua_appearance; return true; } bool DarkThemeAvailable() { - return (__builtin_available(macOS 10.14, *)); + if (__builtin_available(macOS 10.14, *)) { + return true; + } else { + return false; + } } bool IsInDarkTheme() { @@ -56,6 +61,8 @@ // NSApplication* app = [NSApplication sharedApplication]; const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); + if (!app) + return false; // NSAppearance* effectiveAppearance = [app effectiveAppearance]; const id effectiveAppearance = obj_send(app, sel_getUid("effectiveAppearance")); @@ -86,6 +93,8 @@ // NSApplication* app = [NSApplication sharedApplication]; const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); + if (!app) + return false; // NSAppearance* appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua]; const id appearance = @@ -109,6 +118,8 @@ // NSApplication* app = [NSApplication sharedApplication]; const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); + if (!app) + return false; // NSAppearance* appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua]; const id appearance = cls_send(objc_getClass("NSAppearance"), sel_getUid("appearanceNamed:"), NSAppearanceNameAqua); @@ -126,6 +137,8 @@ // NSApplication* app = [NSApplication sharedApplication]; const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); + if (!app) + return; // [app setAppearance: null]; obj_send(app, sel_getUid("setAppearance:"), nullptr);