summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/HBAudio.m7
-rw-r--r--macosx/HBAudioDefaults.m7
-rw-r--r--macosx/HBCodingUtilities.h13
-rw-r--r--macosx/HBCore.m7
-rw-r--r--macosx/HBDistributedArray.m23
-rw-r--r--macosx/HBHUD.h3
-rw-r--r--macosx/HBJob.m3
-rw-r--r--macosx/HBRemoteCore.m2
-rw-r--r--macosx/HBSubtitles.m7
-rw-r--r--macosx/HBSubtitlesDefaults.m3
-rw-r--r--macosx/HandBrakeKitTests/HBJobTests.m2
11 files changed, 31 insertions, 46 deletions
diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m
index adbee0e3e..549c87d34 100644
--- a/macosx/HBAudio.m
+++ b/macosx/HBAudio.m
@@ -278,10 +278,9 @@ NSString *HBAudioEncoderChangedNotification = @"HBAudioEncoderChangedNotificatio
self = [super init];
decodeInt(_container); if (_container != HB_MUX_MP4 && _container != HB_MUX_MKV && _container != HB_MUX_WEBM) { goto fail; }
- decodeCollectionOfObjects(_sourceTracks, NSArray, HBTitleAudioTrack);
- if (_sourceTracks == nil || _sourceTracks.count < 1) { goto fail; }
- decodeCollectionOfObjects(_tracks, NSMutableArray, HBAudioTrack);
- if (_tracks == nil) { goto fail; }
+ decodeCollectionOfObjectsOrFail(_sourceTracks, NSArray, HBTitleAudioTrack);
+ if (_sourceTracks.count < 1) { goto fail; }
+ decodeCollectionOfObjectsOrFail(_tracks, NSMutableArray, HBAudioTrack);
for (HBAudioTrack *track in _tracks)
{
diff --git a/macosx/HBAudioDefaults.m b/macosx/HBAudioDefaults.m
index b7ec8d20d..3041927a1 100644
--- a/macosx/HBAudioDefaults.m
+++ b/macosx/HBAudioDefaults.m
@@ -474,11 +474,8 @@
goto fail;
}
- decodeCollectionOfObjects(_trackSelectionLanguages, NSMutableArray, NSString);
- if (_trackSelectionLanguages == nil) { goto fail; }
-
- decodeCollectionOfObjects(_tracksArray, NSMutableArray, HBAudioTrackPreset);
- if (_tracksArray == nil) { goto fail; }
+ decodeCollectionOfObjectsOrFail(_trackSelectionLanguages, NSMutableArray, NSString);
+ decodeCollectionOfObjectsOrFail(_tracksArray, NSMutableArray, HBAudioTrackPreset);
decodeBool(_allowAACPassthru);
decodeBool(_allowAC3Passthru);
diff --git a/macosx/HBCodingUtilities.h b/macosx/HBCodingUtilities.h
index e0f3e1f04..556d57b52 100644
--- a/macosx/HBCodingUtilities.h
+++ b/macosx/HBCodingUtilities.h
@@ -19,15 +19,10 @@
#define decodeDouble(x) x = [decoder decodeDoubleForKey:OBJC_STRINGIFY(x)]
#define decodeObject(x, cl) x = [decoder decodeObjectOfClass:[cl class] forKey:OBJC_STRINGIFY(x)];
-#define decodeCollectionOfObjects(x, cl, objectcl) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], nil] forKey:OBJC_STRINGIFY(x)];
-
-#define decodeCollectionOfObjects2(x, cl, objectcl, objectcl2) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], nil] forKey:OBJC_STRINGIFY(x)];
-
-#define decodeCollectionOfObjects3(x, cl, objectcl, objectcl2, objectcl3) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], [objectcl3 class], nil] forKey:OBJC_STRINGIFY(x)];
+#define fail(x) [decoder failWithError:[NSError errorWithDomain:@"HBKitErrorDomain" code:1 userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to decode %@", OBJC_STRINGIFY(x)]}]]; goto fail;
-#define decodeCollectionOfObjects4(x, cl, objectcl, objectcl2, objectcl3, objectcl4) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], [objectcl3 class], [objectcl4 class], nil] forKey:OBJC_STRINGIFY(x)];
-
-#define decodeCollectionOfObjects5(x, cl, objectcl, objectcl2, objectcl3, objectcl4, objectcl5) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], [objectcl3 class], [objectcl4 class], [objectcl5 class], nil] forKey:OBJC_STRINGIFY(x)];
+#define decodeCollectionOfObjects(x, cl, objectcl) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], nil] forKey:OBJC_STRINGIFY(x)];
+#define decodeCollectionOfObjectsOrFail(x, cl, objectcl) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], nil] forKey:OBJC_STRINGIFY(x)]; if (x == nil || ![x isKindOfClass:[cl class]]) { fail(x) }
-#define decodeObjectOrFail(x, cl) x = [decoder decodeObjectOfClass:[cl class] forKey:OBJC_STRINGIFY(x)]; if (x == nil) {NSLog(@"Failed to decode: %@", OBJC_STRINGIFY(x)); goto fail;}
+#define decodeObjectOrFail(x, cl) x = [decoder decodeObjectOfClass:[cl class] forKey:OBJC_STRINGIFY(x)]; if (x == nil) { fail(x) }
diff --git a/macosx/HBCore.m b/macosx/HBCore.m
index e7f988a95..d3dca8d7b 100644
--- a/macosx/HBCore.m
+++ b/macosx/HBCore.m
@@ -187,7 +187,7 @@ typedef void (^HBCoreCleanupHandler)(void);
NSAssert(url, @"[HBCore canScan:] called with nil url.");
#ifdef __SANDBOX_ENABLED__
- BOOL accessingSecurityScopedResource = [url startAccessingSecurityScopedResource];
+ HBSecurityAccessToken *token = [HBSecurityAccessToken tokenWithObject:url];
#endif
if (![[NSFileManager defaultManager] fileExistsAtPath:url.path]) {
@@ -235,10 +235,7 @@ typedef void (^HBCoreCleanupHandler)(void);
}
#ifdef __SANDBOX_ENABLED__
- if (accessingSecurityScopedResource)
- {
- [url stopAccessingSecurityScopedResource];
- }
+ token = nil;
#endif
return YES;
diff --git a/macosx/HBDistributedArray.m b/macosx/HBDistributedArray.m
index 2cb39023d..1abce6094 100644
--- a/macosx/HBDistributedArray.m
+++ b/macosx/HBDistributedArray.m
@@ -194,20 +194,21 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk";
*/
- (void)reload
{
- NSMutableArray<HBUniqueObject> *jobsArray = nil;
- @try
- {
- NSData *queue = [NSData dataWithContentsOfURL:self.fileURL];
- NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:queue];
- unarchiver.requiresSecureCoding = YES;
- jobsArray = [unarchiver decodeObjectOfClasses:self.objectClasses forKey:NSKeyedArchiveRootObjectKey];
- [unarchiver finishDecoding];
- }
- @catch (NSException *exception)
+ NSMutableArray<HBUniqueObject> *jobsArray;
+ NSError *error;
+
+ NSData *queue = [NSData dataWithContentsOfURL:self.fileURL];
+ NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:queue];
+ unarchiver.requiresSecureCoding = YES;
+ jobsArray = [unarchiver decodeTopLevelObjectOfClasses:self.objectClasses forKey:NSKeyedArchiveRootObjectKey error:&error];
+
+ if (error)
{
- jobsArray = nil;
+ [HBUtilities writeErrorToActivityLog:error];
}
+ [unarchiver finishDecoding];
+
// Swap the proxy objects representation with the new
// one read from disk
NSMutableArray *proxyArray = [NSMutableArray array];
diff --git a/macosx/HBHUD.h b/macosx/HBHUD.h
index a46c02aa9..eaa138e09 100644
--- a/macosx/HBHUD.h
+++ b/macosx/HBHUD.h
@@ -11,8 +11,7 @@
- (BOOL)canBeHidden;
// Responder chains is nice and good, but NSViewController
-// are not automatically inserted in the responder chain prior 10.10
-// and are removed when the view is hidden, so let's deliver the
+// are removed when the view is hidden, so let's deliver the
// events manually.
- (BOOL)HB_keyDown:(NSEvent *)event;
diff --git a/macosx/HBJob.m b/macosx/HBJob.m
index 9bf41c49a..bde7ffa2e 100644
--- a/macosx/HBJob.m
+++ b/macosx/HBJob.m
@@ -481,8 +481,7 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification";
_video.job = self;
decodeBool(_chaptersEnabled);
- decodeCollectionOfObjects(_chapterTitles, NSArray, HBChapter);
- if (_chapterTitles == nil) { goto fail; }
+ decodeCollectionOfObjectsOrFail(_chapterTitles, NSArray, HBChapter);
return self;
}
diff --git a/macosx/HBRemoteCore.m b/macosx/HBRemoteCore.m
index abb1a375e..0cc410e79 100644
--- a/macosx/HBRemoteCore.m
+++ b/macosx/HBRemoteCore.m
@@ -64,7 +64,7 @@
_proxy = [_connection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
dispatch_sync(dispatch_get_main_queue(), ^{
[self forwardError:@"XPC: Service did report an error\n"];
- [self forwardError:error.description];
+ [HBUtilities writeErrorToActivityLog:error];
});
}];
diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m
index 8545d37d5..8119813ea 100644
--- a/macosx/HBSubtitles.m
+++ b/macosx/HBSubtitles.m
@@ -461,10 +461,9 @@
_tokens = [NSMutableArray array];
decodeInt(_container); if (_container != HB_MUX_MP4 && _container != HB_MUX_MKV && _container != HB_MUX_WEBM) { goto fail; }
- decodeCollectionOfObjects(_sourceTracks, NSArray, HBTitleSubtitlesTrack);
- if (_sourceTracks == nil || _sourceTracks.count < 1) { goto fail; }
- decodeCollectionOfObjects(_tracks, NSMutableArray, HBSubtitlesTrack);
- if (_tracks == nil) { goto fail; }
+ decodeCollectionOfObjectsOrFail(_sourceTracks, NSArray, HBTitleSubtitlesTrack);
+ if (_sourceTracks.count < 1) { goto fail; }
+ decodeCollectionOfObjectsOrFail(_tracks, NSMutableArray, HBSubtitlesTrack);
for (HBSubtitlesTrack *track in _tracks)
{
diff --git a/macosx/HBSubtitlesDefaults.m b/macosx/HBSubtitlesDefaults.m
index dfd71d3de..6c342cd7a 100644
--- a/macosx/HBSubtitlesDefaults.m
+++ b/macosx/HBSubtitlesDefaults.m
@@ -230,8 +230,7 @@
{
goto fail;
}
- decodeCollectionOfObjects(_trackSelectionLanguages, NSMutableArray, NSString);
- if (_trackSelectionLanguages == nil) { goto fail; }
+ decodeCollectionOfObjectsOrFail(_trackSelectionLanguages, NSMutableArray, NSString);
decodeBool(_addForeignAudioSearch);
decodeBool(_addForeignAudioSubtitle);
diff --git a/macosx/HandBrakeKitTests/HBJobTests.m b/macosx/HandBrakeKitTests/HBJobTests.m
index 9848bbe5b..e61df46d8 100644
--- a/macosx/HandBrakeKitTests/HBJobTests.m
+++ b/macosx/HandBrakeKitTests/HBJobTests.m
@@ -46,7 +46,7 @@
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
self.core = [[HBCore alloc] initWithLogLevel:1 queue:self.queue];
- [self.core scanURL:sampleURL titleIndex:0 previews:1 minDuration:0 progressHandler:^(HBState state, HBProgress progress, NSString * _Nonnull info) {
+ [self.core scanURL:sampleURL titleIndex:0 previews:1 minDuration:0 keepPreviews:NO progressHandler:^(HBState state, HBProgress progress, NSString * _Nonnull info) {
} completionHandler:^(HBCoreResult result) {
dispatch_semaphore_signal(sem);