MacGui: disable the cancel button while the queue is scanning because there isn't...
authorritsuka <damiog@gmail.com>
Tue, 27 Jan 2015 11:31:50 +0000 (11:31 +0000)
committerritsuka <damiog@gmail.com>
Tue, 27 Jan 2015 11:31:50 +0000 (11:31 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6818 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBController.m
macosx/HBCore.m
macosx/HBPreviewGenerator.m
macosx/HBQueueController.m

index 75c3c5ef114ad9e6746a55ca379ca1fcc8759103..3ada22255dad42d5f2a6edabe921e84cb6d65de2 100644 (file)
             [toolbarItem setLabel: @"Stop"];
             [toolbarItem setPaletteLabel: @"Stop"];
             [toolbarItem setToolTip: @"Stop Encoding"];
-            return YES;
+            return (queueState != HBStateScanning);
         }
         if (action == @selector(pause:))
         {
index 8446a6a33449b693693ae09ef3a4ed588cf462d4..dbbbb790e66a63bbeb7bf3ee1b2002c132320198 100644 (file)
@@ -246,7 +246,6 @@ static void hb_error_handler(const char *errmsg)
 {
     if (self.isCancelled)
     {
-        self.cancelled = NO;
         return NO;
     }
 
@@ -385,15 +384,7 @@ static void hb_error_handler(const char *errmsg)
 
     [HBUtilities writeToActivityLog:"%s work done", self.name.UTF8String];
 
-    if (self.isCancelled)
-    {
-        self.cancelled = NO;
-        return NO;
-    }
-    else
-    {
-        return YES;
-    }
+    return self.isCancelled || (_hb_state->param.workdone.error == 0);
 }
 
 - (void)cancelEncode
@@ -403,7 +394,6 @@ static void hb_error_handler(const char *errmsg)
     [HBUtilities writeToActivityLog:"%s encode cancelled", self.name.UTF8String];
 }
 
-
 - (void)pause
 {
     hb_pause(_hb_handle);
@@ -519,6 +509,9 @@ static void hb_error_handler(const char *errmsg)
     {
         [self handleScanCompletion];
     }
+
+    // Reset the cancelled state.
+    self.cancelled = NO;
 }
 
 /**
index 61ed448bbc8e5663cdfecf80fb692752aad4c93a..a4dba01f3205cbcc53a17f805df4037f615b3d6b 100644 (file)
 - (void) dealloc
 {
     [self.core cancelEncode];
-    [_core release];
-    _core = nil;
 
     [_picturePreviews release];
     _picturePreviews = nil;
index 2e4249fb8d40c2cdb5805fd6248187aa35bc74f7..054db0568f05d471060120fc948088560fb1db42 100644 (file)
             menuItem.title = NSLocalizedString(@"Stop Encoding", nil);
             menuItem.keyEquivalent = @".";
 
-            return YES;
+            return self.core.state != HBStateScanning;
         }
     }
 
 
     if (action == @selector(toggleStartCancel:))
     {
-        if ((s == HBStatePaused) || (s == HBStateWorking) || (s == HBStateMuxing))
+        if ((s == HBStateScanning) || (s == HBStatePaused) || (s == HBStateWorking) || (s == HBStateMuxing))
         {
             theItem.image = [NSImage imageNamed:@"stopencode"];
             theItem.label = NSLocalizedString(@"Stop", @"");
             theItem.toolTip = NSLocalizedString(@"Stop Encoding", @"");
-            return YES;
+            return s != HBStateScanning;
         }
         else
         {
         // now we mark the queue item as working so another instance can not come along and try to scan it while we are scanning
         self.currentJob.state = HBJobStateWorking;
 
+        // Tell HB to output a new activity log file for this encode
+        [self.outputPanel startEncodeLog:self.currentJob.destURL];
+
         // now we can go ahead and scan the new pending queue item
         [self performScan:self.currentJob.fileURL titleIdx:self.currentJob.titleIdx];
     }
  */
 - (void)performScan:(NSURL *)scanURL titleIdx:(NSInteger)index
 {
-    // Tell HB to output a new activity log file for this encode
-    [self.outputPanel startEncodeLog:self.currentJob.destURL];
-
     // Only scan 10 previews before an encode - additional previews are
     // only useful for autocrop and static previews, which are already taken care of at this point
     [self.core scanURL:scanURL
          progressHandler:^(HBState state, hb_state_t hb_state) {
              NSMutableString *string = nil;
              CGFloat progress = 0;
+             #define p hb_state.param.working
              switch (state)
              {
                  case HBStateSearching:
                  {
-                     #define p hb_state.param.working
                      string = [NSMutableString stringWithFormat:
                                NSLocalizedString(@"Searching for start point… :  %.2f %%", @""),
                                100.0 * p.progress];
                      {
                          [string appendFormat:NSLocalizedString(@" (ETA %02dh%02dm%02ds)", @"" ), p.hours, p.minutes, p.seconds];
                      }
-                     #undef p
 
                      break;
                  }
                  case HBStateWorking:
                  {
-                     #define p hb_state.param.working
                      NSString *pass_desc = @"";
                      if (p.job_cur == 1 && p.job_count > 1)
                      {
 
                          self.dockIconProgress += dockTileUpdateFrequency;
                      }
-                    #undef p
 
                      break;
                  }
                  default:
                      break;
              }
+             #undef p
 
              // Update text field
              self.progressTextField.stringValue = string;