]> granicus.if.org Git - handbrake/commitdiff
MacGui: Fix issue with queue where cancelling a two pass job during the first pass...
authordynaflash <dynaflashtech@gmail.com>
Thu, 20 Nov 2008 20:52:03 +0000 (20:52 +0000)
committerdynaflash <dynaflashtech@gmail.com>
Thu, 20 Nov 2008 20:52:03 +0000 (20:52 +0000)
- addresses bug reported here http://forum.handbrake.fr/viewtopic.php?f=12&t=7420

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1936 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.mm

index 7681c1f3fc63ece8f9cfc9477c33c30941cc0ce9..a1ab827e4510970ebeb93814fd8ddedeac3deec5 100644 (file)
@@ -3046,46 +3046,6 @@ fWorkingCount = 0;
 }
 
 
-//------------------------------------------------------------------------------------
-// Cancels and deletes the current job and stops libhb from processing the remaining
-// encodes.
-//------------------------------------------------------------------------------------
-- (void) doCancelCurrentJob
-{
-    // Stop the current job. hb_stop will only cancel the current pass and then set
-    // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we
-    // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the
-    // remaining passes of the job and then start the queue back up if there are any
-    // remaining jobs.
-     
-    
-    hb_stop( fQueueEncodeLibhb );
-    fEncodeState = 2;   // don't alert at end of processing since this was a cancel
-    
-    // now that we've stopped the currently encoding job, lets mark it as cancelled
-    [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"];
-    // and as always, save it in the queue .plist...
-    /* We save all of the Queue data here */
-    [self saveQueueFileItem];
-    // so now lets move to 
-    currentQueueEncodeIndex++ ;
-    // ... and see if there are more items left in our queue
-    int queueItems = [QueueFileArray count];
-    /* If we still have more items in our queue, lets go to the next one */
-    if (currentQueueEncodeIndex < queueItems)
-    {
-    [self writeToActivityLog: "doCancelCurrentJob currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex];
-    [self writeToActivityLog: "doCancelCurrentJob moving to the next job"];
-    
-    [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]];
-    }
-    else
-    {
-        [self writeToActivityLog: "doCancelCurrentJob the item queue is complete"];
-    }
-
-}
-
 //------------------------------------------------------------------------------------
 // Displays an alert asking user if the want to cancel encoding of current job.
 // Cancel: returns immediately after posting the alert. Later, when the user
@@ -3130,9 +3090,62 @@ fWorkingCount = 0;
     }
 }
 
+//------------------------------------------------------------------------------------
+// Cancels and deletes the current job and stops libhb from processing the remaining
+// encodes.
+//------------------------------------------------------------------------------------
+- (void) doCancelCurrentJob
+{
+    // Stop the current job. hb_stop will only cancel the current pass and then set
+    // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we
+    // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the
+    // remaining passes of the job and then start the queue back up if there are any
+    // remaining jobs.
+     
+    
+    hb_stop( fQueueEncodeLibhb );
+    
+    // Delete all remaining jobs since libhb doesn't do this on its own.
+            hb_job_t * job;
+            while( ( job = hb_job(fQueueEncodeLibhb, 0) ) )
+                hb_rem( fQueueEncodeLibhb, job );
+                
+    fEncodeState = 2;   // don't alert at end of processing since this was a cancel
+    
+    // now that we've stopped the currently encoding job, lets mark it as cancelled
+    [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"];
+    // and as always, save it in the queue .plist...
+    /* We save all of the Queue data here */
+    [self saveQueueFileItem];
+    // so now lets move to 
+    currentQueueEncodeIndex++ ;
+    // ... and see if there are more items left in our queue
+    int queueItems = [QueueFileArray count];
+    /* If we still have more items in our queue, lets go to the next one */
+    if (currentQueueEncodeIndex < queueItems)
+    {
+    [self writeToActivityLog: "doCancelCurrentJob currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex];
+    [self writeToActivityLog: "doCancelCurrentJob moving to the next job"];
+    
+    [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]];
+    }
+    else
+    {
+        [self writeToActivityLog: "doCancelCurrentJob the item queue is complete"];
+    }
+
+}
+
 - (void) doCancelCurrentJobAndStop
 {
     hb_stop( fQueueEncodeLibhb );
+    
+    // Delete all remaining jobs since libhb doesn't do this on its own.
+            hb_job_t * job;
+            while( ( job = hb_job(fQueueEncodeLibhb, 0) ) )
+                hb_rem( fQueueEncodeLibhb, job );
+                
+                
     fEncodeState = 2;   // don't alert at end of processing since this was a cancel
     
     // now that we've stopped the currently encoding job, lets mark it as cancelled