From 4df869c309f3a5219f40cec3c6c51916f4afa135 Mon Sep 17 00:00:00 2001 From: rogerman Date: Thu, 7 Apr 2022 16:28:50 -0700 Subject: [PATCH] Cocoa Port: Fix a potential crash on startup if Metal is not available. (Regression from commit 6833e315.) - Also change one of Apple's Metal enums to an older version to fix a compiling issue with Xcode 8. --- .../cocoa/userinterface/MacMetalDisplayView.mm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm b/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm index 6b8860a73..b871941dc 100644 --- a/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm +++ b/desmume/src/frontend/cocoa/userinterface/MacMetalDisplayView.mm @@ -89,7 +89,7 @@ { tempVersionStr = (isRWTexSupported) ? @"macOS Metal GPUFamily1_v2 w/ Tier2 R/W Textures" : @"macOS Metal GPUFamily1_v2"; } - else if ([device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) + else if ([device supportsFeatureSet:MTLFeatureSet_OSX_GPUFamily1_v1]) { tempVersionStr = (isRWTexSupported) ? @"macOS Metal GPUFamily1_v1 w/ Tier2 R/W Textures" : @"macOS Metal GPUFamily1_v1"; } @@ -2456,8 +2456,12 @@ MacMetalFetchObject::MacMetalFetchObject() } _clientData = [[MetalDisplayViewSharedData alloc] init]; - strlcpy(_name, [[(MetalDisplayViewSharedData *)_clientData name] cStringUsingEncoding:NSUTF8StringEncoding], sizeof(_name) - 1); - strlcpy(_description, [[(MetalDisplayViewSharedData *)_clientData description] cStringUsingEncoding:NSUTF8StringEncoding], sizeof(_description) - 1); + + if (_clientData != nil) + { + strlcpy(_name, [[(MetalDisplayViewSharedData *)_clientData name] cStringUsingEncoding:NSUTF8StringEncoding], sizeof(_name) - 1); + strlcpy(_description, [[(MetalDisplayViewSharedData *)_clientData description] cStringUsingEncoding:NSUTF8StringEncoding], sizeof(_description) - 1); + } } MacMetalFetchObject::~MacMetalFetchObject()