diff options
author | Damiano Galassi <[email protected]> | 2019-08-11 10:28:23 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2019-08-11 10:28:23 +0200 |
commit | 0269063fae2c1f23c36196df9741a846911217a4 (patch) | |
tree | eeaa7f3c28d2711ea89bc13f0801863f75eb3ea6 | |
parent | 757efe91236febe8a2773b1b1abb3c6595fbf23f (diff) |
MacGui: properly cleanup the xpc service temporary files; fix encode toolbar items state when going from scanning to encoding.
-rw-r--r-- | macosx/HBQueue.h | 1 | ||||
-rw-r--r-- | macosx/HBQueue.m | 7 | ||||
-rw-r--r-- | macosx/HBRemoteCore.m | 10 |
3 files changed, 10 insertions, 8 deletions
diff --git a/macosx/HBQueue.h b/macosx/HBQueue.h index 036df8d27..6cbc9f4ce 100644 --- a/macosx/HBQueue.h +++ b/macosx/HBQueue.h @@ -13,7 +13,6 @@ NS_ASSUME_NONNULL_BEGIN extern NSString * const HBQueueDidChangeStateNotification; -extern NSString * const HBQueueNotificationStateKey; // HBState extern NSString * const HBQueueDidAddItemNotification; extern NSString * const HBQueueDidRemoveItemNotification; diff --git a/macosx/HBQueue.m b/macosx/HBQueue.m index d85c662d4..c0e3d1b1c 100644 --- a/macosx/HBQueue.m +++ b/macosx/HBQueue.m @@ -13,7 +13,6 @@ static void *HBQueueContext = &HBQueueContext; NSString * const HBQueueDidChangeStateNotification = @"HBQueueDidChangeStateNotification"; -NSString * const HBQueueNotificationStateKey = @"HBQueueNotificationStateKey"; NSString * const HBQueueDidAddItemNotification = @"HBQueueDidAddItemNotification"; NSString * const HBQueueDidRemoveItemNotification = @"HBQueueDidRemoveItemNotification"; @@ -86,7 +85,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK { if (context == HBQueueContext) { - [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self userInfo:@{HBQueueNotificationStateKey: @(self.core.state)}]; + [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self]; } else { @@ -437,7 +436,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK - (BOOL)isEncoding { HBState s = self.core.state; - return (s == HBStateScanning) || (s == HBStatePaused) || (s == HBStateWorking) || (s == HBStateMuxing) || (s == HBStateSearching); + return self.currentItem || (s == HBStateScanning) || (s == HBStatePaused) || (s == HBStateWorking) || (s == HBStateMuxing) || (s == HBStateSearching); } - (BOOL)canPause @@ -501,7 +500,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK self.failedItemsCount = failedCount; self.completedItemsCount = completedCount; - [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self userInfo:@{HBQueueNotificationStateKey: @(self.core.state)}]; + [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeStateNotification object:self]; } - (BOOL)isDiskSpaceLowAtURL:(NSURL *)url diff --git a/macosx/HBRemoteCore.m b/macosx/HBRemoteCore.m index 7ed606ae2..b239cbaab 100644 --- a/macosx/HBRemoteCore.m +++ b/macosx/HBRemoteCore.m @@ -59,7 +59,6 @@ [_connection resume]; } - - (void)invalidate { [[_connection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {}] tearDown]; @@ -71,6 +70,7 @@ { if (self.state != HBStateIdle) { + [self forwardError:@"XPC Service did crash"]; self.progressHandler = nil; if (self.completionHandler) { @@ -129,8 +129,10 @@ [_proxy scanURL:url titleIndex:index previews:previewsNum minDuration:seconds withReply:^(HBCoreResult result) { dispatch_sync(dispatch_get_main_queue(), ^{ + HBCoreCompletionHandler handler = weakSelf.completionHandler; + weakSelf.completionHandler = nil; weakSelf.progressHandler = nil; - weakSelf.completionHandler(result); + handler(result); }); }]; } @@ -154,8 +156,10 @@ [_proxy encodeJob:job withReply:^(HBCoreResult result) { dispatch_sync(dispatch_get_main_queue(), ^{ + HBCoreCompletionHandler handler = weakSelf.completionHandler; + weakSelf.completionHandler = nil; weakSelf.progressHandler = nil; - weakSelf.completionHandler(result); + handler(result); }); }]; } |