]> granicus.if.org Git - handbrake/commitdiff
MacGui: properly cleanup the xpc service temporary files; fix encode toolbar items...
authorDamiano Galassi <damiog@gmail.com>
Sun, 11 Aug 2019 08:28:23 +0000 (10:28 +0200)
committerDamiano Galassi <damiog@gmail.com>
Sun, 11 Aug 2019 08:28:23 +0000 (10:28 +0200)
macosx/HBQueue.h
macosx/HBQueue.m
macosx/HBRemoteCore.m

index 036df8d275f68f75403e2b020b757545c7481be5..6cbc9f4cef0db2b262ee860c5f2b14988bd04a4c 100644 (file)
@@ -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;
index d85c662d433acfa26fb3df2ad23ee064cd160159..c0e3d1b1c5ce6b9952a530050672028d3680c671 100644 (file)
@@ -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
index 7ed606ae2e9ebddf597ccff076257a47c147e035..b239cbaabcf577848fc36d120a2237ca06801539 100644 (file)
@@ -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)
         {
 
     [_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);
         });
     }];
 }
 
     [_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);
         });
     }];
 }