diff --git a/Classes/SBDocument.m b/Classes/SBDocument.m index d09f382..c858a46 100755 --- a/Classes/SBDocument.m +++ b/Classes/SBDocument.m @@ -26,7 +26,7 @@ #define SublerTableViewDataType @"SublerTableViewDataType" -@interface SBDocument () +@interface SBDocument () @property (nonatomic, retain) MP42File *mp4; @@ -75,7 +75,7 @@ - (instancetype)initWithType:(NSString *)typeName error:(NSError **)outError { if (self = [super initWithType:typeName error:outError]) { - self.mp4 = [[[MP42File alloc] initWithDelegate:self] autorelease]; + self.mp4 = [[[MP42File alloc] init] autorelease]; } return self; @@ -96,7 +96,7 @@ - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError { - self.mp4 = [[[MP42File alloc] initWithURL:absoluteURL delegate:self] autorelease]; + self.mp4 = [[[MP42File alloc] initWithURL:absoluteURL] autorelease]; if (outError != NULL && !self.mp4) { *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL]; @@ -109,7 +109,7 @@ - (BOOL)revertToContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError { - self.mp4 = [[[MP42File alloc] initWithURL:absoluteURL delegate:self] autorelease]; + self.mp4 = [[[MP42File alloc] initWithURL:absoluteURL] autorelease]; [fileTracksTable reloadData]; [self reloadPropertyView]; @@ -174,6 +174,13 @@ BOOL result = NO; NSDictionary *attributes = [self saveAttributes]; + self.mp4.progressHandler = ^(double progress){ + dispatch_async(dispatch_get_main_queue(), ^{ + [optBar setIndeterminate:NO]; + [optBar setDoubleValue:progress]; + }); + }; + switch (saveOperation) { case NSSaveOperation: // movie file already exists, so we'll just update @@ -199,6 +206,8 @@ _optimize = NO; } + self.mp4.progressHandler = nil; + if (io_success == kIOReturnSuccess) { IOPMAssertionRelease(assertionID); } @@ -207,7 +216,7 @@ MP42File *reloadedFile = nil; if (result == YES) { - reloadedFile = [[MP42File alloc] initWithURL:[NSURL fileURLWithPath:url.path] delegate:self]; + reloadedFile = [[MP42File alloc] initWithURL:[NSURL fileURLWithPath:url.path]]; } dispatch_sync(dispatch_get_main_queue(), ^{ @@ -324,14 +333,6 @@ #pragma mark - Interface validation -- (void)progressStatus:(CGFloat)progress -{ - dispatch_async(dispatch_get_main_queue(), ^{ - [optBar setIndeterminate:NO]; - [optBar setDoubleValue:progress]; - }); -} - - (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem { SEL action = [anItem action]; @@ -816,7 +817,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn } else { MP42File *file = nil; - if ((file = [[MP42File alloc] initWithURL:URL delegate:self])) { + if ((file = [[MP42File alloc] initWithURL:URL])) { [self.mp4.metadata mergeMetadata:file.metadata]; [file release]; } diff --git a/Classes/SBQueue.m b/Classes/SBQueue.m index bdb57be..a186041 100644 --- a/Classes/SBQueue.m +++ b/Classes/SBQueue.m @@ -240,7 +240,7 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification"; [self.currentItem cancel]; } -- (void)progressStatus:(CGFloat)progress { +- (void)progressStatus:(double)progress { [self handleSBStatusWorking:progress index:-1]; } diff --git a/Classes/SBQueueItem.m b/Classes/SBQueueItem.m index 78f1ed6..24cce51 100755 --- a/Classes/SBQueueItem.m +++ b/Classes/SBQueueItem.m @@ -15,7 +15,7 @@ #define ALMOST_4GiB 4000000000 -@interface SBQueueItem () +@interface SBQueueItem () @property (nonatomic, readwrite) NSString *localizedWorkingDescription; @@ -179,7 +179,7 @@ [self.URL getResourceValue:&type forKey:NSURLTypeIdentifierKey error:outError]; if ([type isEqualToString:@"com.apple.m4a-audio"] || [type isEqualToString:@"com.apple.m4v-video"] || [type isEqualToString:@"public.mpeg-4"]) { - self.mp4File = [[[MP42File alloc] initWithURL:self.URL delegate:nil] autorelease]; + self.mp4File = [[[MP42File alloc] initWithURL:self.URL] autorelease]; } else { self.mp4File = [[[MP42File alloc] init] autorelease]; MP42FileImporter *fileImporter = [[MP42FileImporter alloc] initWithURL:self.URL error:outError]; @@ -261,7 +261,7 @@ for (id action in self.actions) { self.localizedWorkingDescription = action.localizedDescription; - [self progressStatus:0]; + [self.delegate progressStatus:0]; [action runAction:self]; } @@ -285,7 +285,9 @@ if (!noErr) { goto bail; } - self.mp4File.delegate = self; + self.mp4File.progressHandler = ^(double progress){ + [self.delegate progressStatus:progress]; + }; // Check if there is enough space on the destination disk if (![self.URL isEqualTo:self.destURL]) { @@ -341,6 +343,7 @@ } bail: + self.mp4File.progressHandler = nil; self.mp4File = nil; [self willChangeValueForKey:@"actions"]; @@ -360,8 +363,6 @@ bail: [self.mp4File cancel]; } -#pragma mark MP42File delegate - - (void)progressStatus:(CGFloat)progress { [self.delegate progressStatus:progress]; } diff --git a/MP42Foundation b/MP42Foundation index 0367be9..2d00a04 160000 --- a/MP42Foundation +++ b/MP42Foundation @@ -1 +1 @@ -Subproject commit 0367be9e3f38de2de2e3a340d0a25c72615b81ed +Subproject commit 2d00a04689809e5a7dd54634f1d649f426b6f179