From bd88ea0594b35be21a47a0734a14f6dbcb5b7418 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 21 Apr 2017 15:17:57 +0200 Subject: [PATCH] MacGui: do not use NSSecureCoding on 10.8, it crashes. --- macosx/HBDistributedArray.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/macosx/HBDistributedArray.m b/macosx/HBDistributedArray.m index d56311244..266382166 100644 --- a/macosx/HBDistributedArray.m +++ b/macosx/HBDistributedArray.m @@ -60,6 +60,7 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk"; @property (nonatomic, readwrite) NSTimeInterval modifiedTime; @property (nonatomic, readonly) NSSet *objectClasses; +@property (nonatomic, readonly) BOOL requiresSecureCoding; @property (nonatomic, readonly) sem_t *mutex; @property (nonatomic, readwrite) uint32_t mutexCount; @@ -77,6 +78,12 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk"; _array = [[NSMutableArray alloc] init]; _objectClasses = [NSSet setWithObjects:[NSMutableArray class], objectClass, nil]; + // Enable secure coding only on 10.9 and later + if ([NSURL instancesRespondToSelector:@selector(fileSystemRepresentation)]) + { + _requiresSecureCoding = YES; + } + NSString *identifier = [[NSBundle mainBundle] bundleIdentifier]; NSArray *runningInstances = [NSRunningApplication runningApplicationsWithBundleIdentifier:identifier]; const char *name = [NSString stringWithFormat:@"%@/%@", identifier, _fileURL.lastPathComponent.stringByDeletingPathExtension].UTF8String; @@ -197,7 +204,7 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk"; NSMutableArray *jobsArray = nil; @try { - if ([NSKeyedUnarchiver instancesRespondToSelector:@selector(requiresSecureCoding)]) + if (self.requiresSecureCoding) { NSData *queue = [NSData dataWithContentsOfURL:self.fileURL]; NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:queue]; -- 2.40.0