]> granicus.if.org Git - handbrake/commitdiff
MacGui: fix the "Cancel encode and stop" alert button.
authorritsuka <damiog@gmail.com>
Tue, 20 Jan 2015 08:37:00 +0000 (08:37 +0000)
committerritsuka <damiog@gmail.com>
Tue, 20 Jan 2015 08:37:00 +0000 (08:37 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6779 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBQueueController.mm

index 3b4ccb5d6e9f666271cd63bc588d2eec62d46e2c..b835599a937067a951830dac900a2a21c003ae40 100644 (file)
@@ -43,6 +43,8 @@
 @property (nonatomic, readonly) HBDistributedArray *jobs;
 @property (nonatomic, retain)   HBJob *currentJob;
 
+@property (nonatomic, readwrite) BOOL stop;
+
 @property (nonatomic, readwrite) NSUInteger pendingItemsCount;
 @property (nonatomic, readwrite) NSUInteger workingItemsCount;
 
     self.currentJob = nil;
 
     // since we have successfully completed an encode, we go to the next
-    [self encodeNextQueueItem];
+    if (!self.stop)
+    {
+        [self encodeNextQueueItem];
+    }
+    self.stop = NO;
 
     [self.window.toolbar validateVisibleItems];
     [self reloadQueue];
 }
 
 /**
- * Cancels and deletes the current job and starts processing the next in queue.
+ * Cancels the current job
  */
 - (void)doCancelCurrentJob
+{
+    self.currentJob.state = HBJobStateCanceled;
+
+    if (self.core.state == HBStateScanning)
+    {
+        [self.core cancelScan];
+    }
+    else
+    {
+        [self.core cancelEncode];
+    }
+}
+
+/**
+ * Cancels the current job and starts processing the next in queue.
+ */
+- (void)cancelCurrentJobAndContinue
 {
     [self.jobs beginTransaction];
 
-    self.currentJob.state = HBJobStateCanceled;
-    [self.core cancelEncode];
+    [self doCancelCurrentJob];
 
     [self.jobs commit];
     [self reloadQueue];
 }
 
 /**
- * Cancels and deletes the current job and stops libhb from processing the remaining encodes.
+ * Cancels the current job and stops libhb from processing the remaining encodes.
  */
-- (void)doCancelCurrentJobAndStop
+- (void)cancelCurrentJobAndStop
 {
     [self.jobs beginTransaction];
 
-    self.currentJob.state = HBJobStateCanceled;
-
-    [self.core cancelEncode];
+    self.stop = YES;
+    [self doCancelCurrentJob];
 
     [self.jobs commit];
     [self reloadQueue];
 
     if (returnCode == NSAlertSecondButtonReturn)
     {
-        // We need to save the currently encoding item number first
         NSInteger index = [self.jobs indexOfObject:self.currentJob];
-        // Since we are encoding, we need to let fHBController Cancel this job
-        // upon which it will move to the next one if there is one
-        [self doCancelCurrentJob];
-        // Now, we can go ahead and remove the job we just cancelled since
-        // we have its item number from above
+        [self cancelCurrentJobAndContinue];
         [self removeQueueItemAtIndex:index];
     }
 }
 
     if (returnCode == NSAlertSecondButtonReturn)
     {
-        [self doCancelCurrentJobAndStop];  // <- this also stops libhb
+        [self cancelCurrentJobAndStop];
     }
     else if (returnCode == NSAlertThirdButtonReturn)
     {
-        [self doCancelCurrentJob];
+        [self cancelCurrentJobAndContinue];
     }
 }