Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Fixes a crash on Mohave #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Fixes an issue where cartool crashed on Mohave due to an API change o…
…n CUIThemeFacet. -initWithURL:error: was moved by Apple to CUICatalog.
  • Loading branch information
cdouglass committed Nov 2, 2018
commit 93c1cedd304bb4b4ad987bb1be10e453536b9300
22 changes: 14 additions & 8 deletions cartool/main.m
Expand Up @@ -60,6 +60,7 @@ @interface CUICatalog : NSObject

@property(readonly) bool isVectorBased;

-(id)initWithURL:(NSURL *)URL error:(NSError **)error;
-(id)initWithName:(NSString *)n fromBundle:(NSBundle *)b;
-(id)allKeys;
-(id)allImageNames;
Expand Down Expand Up @@ -149,14 +150,19 @@ void exportCarFileAtPath(NSString * carPath, NSString *outputDirectoryPath)
NSError *error = nil;

outputDirectoryPath = [outputDirectoryPath stringByExpandingTildeInPath];

CUIThemeFacet *facet = [CUIThemeFacet themeWithContentsOfURL:[NSURL fileURLWithPath:carPath] error:&error];

CUICatalog *catalog = [[CUICatalog alloc] init];

/* Override CUICatalog to point to a file rather than a bundle */
[catalog setValue:facet forKey:@"_storageRef"];


CUICatalog *catalog = nil;
if ([CUICatalog instancesRespondToSelector:@selector(initWithURL:error:)]) {
/* If CUICatalog has the URL API (Mojave), use it. */
catalog = [[CUICatalog alloc] initWithURL:[NSURL fileURLWithPath:carPath] error:&error];
} else {
CUIThemeFacet *facet = [CUIThemeFacet themeWithContentsOfURL:[NSURL fileURLWithPath:carPath] error:&error];
catalog = [[CUICatalog alloc] init];
/* Override CUICatalog to point to a file rather than a bundle */
[catalog setValue:facet forKey:@"_storageRef"];
}
NSCAssert(!error, @"Error attempting to open asset catalog (%@): %@", carPath, error);

/* CUICommonAssetStorage won't link */
CUICommonAssetStorage *storage = [[NSClassFromString(@"CUICommonAssetStorage") alloc] initWithPath:carPath];

Expand Down