diff options
author | Damiano Galassi <[email protected]> | 2020-01-10 14:19:50 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2020-01-10 14:19:50 +0100 |
commit | 073c2fb84b3ead86d2f2b28cbd737bb936cc0696 (patch) | |
tree | d3d832cab0e828a1b2ce76a9f858296c4f74fdb8 /macosx/HBSubtitles.m | |
parent | efcd5b85b03145964779b8a7700558e44213b8d8 (diff) |
MacGui: improve security scoped resources management. Fixes #2566.
Diffstat (limited to 'macosx/HBSubtitles.m')
-rw-r--r-- | macosx/HBSubtitles.m | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m index 9d2833df4..405201b15 100644 --- a/macosx/HBSubtitles.m +++ b/macosx/HBSubtitles.m @@ -16,7 +16,6 @@ #import "HBLocalizationUtilities.h" #import "HBUtilities.h" #import "HBJob+Private.h" -#import "HBSecurityAccessToken.h" #include "handbrake/common.h" @@ -27,9 +26,6 @@ @property (nonatomic, readwrite) NSArray<HBTitleSubtitlesTrack *> *sourceTracks; -@property (nonatomic, readonly) NSMutableArray<HBSecurityAccessToken *> *tokens; -@property (nonatomic, readwrite) NSInteger *accessCount; - @property (nonatomic, readwrite, weak) HBJob *job; @property (nonatomic, readwrite) int container; @@ -50,7 +46,6 @@ _tracks = [[NSMutableArray alloc] init]; _defaults = [[HBSubtitlesDefaults alloc] init]; - _tokens = [NSMutableArray array]; NSMutableArray<HBTitleSubtitlesTrack *> *sourceTracks = [job.title.subtitlesTracks mutableCopy]; @@ -376,20 +371,21 @@ }]; } +- (void)refreshSecurityScopedResources +{ + for (HBTitleSubtitlesTrack *sourceTrack in self.sourceTracks) + { + [sourceTrack refreshSecurityScopedResources]; + } +} + - (BOOL)startAccessingSecurityScopedResource { #ifdef __SANDBOX_ENABLED__ - if (self.accessCount == 0) + for (HBTitleSubtitlesTrack *sourceTrack in self.sourceTracks) { - for (HBTitleSubtitlesTrack *sourceTrack in self.sourceTracks) - { - if (sourceTrack.fileURL) - { - [self.tokens addObject:[HBSecurityAccessToken tokenWithObject:sourceTrack.fileURL]]; - } - } + [sourceTrack startAccessingSecurityScopedResource]; } - self.accessCount += 1; return YES; #else return NO; @@ -399,11 +395,9 @@ - (void)stopAccessingSecurityScopedResource { #ifdef __SANDBOX_ENABLED__ - self.accessCount -= 1; - NSAssert(self.accessCount >= 0, @"[HBSubtitles stopAccessingSecurityScopedResource:] unbalanced call"); - if (self.accessCount == 0) + for (HBTitleSubtitlesTrack *sourceTrack in self.sourceTracks) { - [self.tokens removeAllObjects]; + [sourceTrack stopAccessingSecurityScopedResource]; } #endif } @@ -431,7 +425,6 @@ } copy->_defaults = [_defaults copy]; - copy->_tokens = [NSMutableArray array]; } return copy; @@ -458,8 +451,6 @@ { self = [super init]; - _tokens = [NSMutableArray array]; - decodeInt(_container); if (_container != HB_MUX_MP4 && _container != HB_MUX_MKV && _container != HB_MUX_WEBM) { goto fail; } decodeCollectionOfObjectsOrFail(_sourceTracks, NSArray, HBTitleSubtitlesTrack); if (_sourceTracks.count < 1) { goto fail; } |