]> granicus.if.org Git - handbrake/commitdiff
MacGui: fix an issue where the the user was already asked if he wanted to delete...
authorritsuka <damiog@gmail.com>
Wed, 22 Jul 2015 12:02:56 +0000 (12:02 +0000)
committerritsuka <damiog@gmail.com>
Wed, 22 Jul 2015 12:02:56 +0000 (12:02 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7360 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBQueueController.m

index d43c43d70bf56bdf6fb17a7288c42ba5fb057676..c366ce14e4506f6e014a367c556a5c257be00949 100644 (file)
     if (targetedRows.count)
     {
         [self.jobs beginTransaction];
+
         // if this is a currently encoding job, we need to be sure to alert the user,
         // to let them decide to cancel it first, then if they do, we can come back and
         // remove it
         NSIndexSet *workingIndexes = [self.jobs indexesOfObjectsUsingBlock:^BOOL(HBJob *item) {
             return item.state == HBJobStateWorking;
         }];
-        NSArray *workingJobs = [self.jobs filteredArrayUsingBlock:^BOOL(HBJob *item) {
-            return item.state == HBJobStateWorking;
-        }];
 
-        [targetedRows removeIndexes:workingIndexes];
+        if ([targetedRows containsIndexes:workingIndexes])
+        {
+            [targetedRows removeIndexes:workingIndexes];
+            NSArray *workingJobs = [self.jobs filteredArrayUsingBlock:^BOOL(HBJob *item) {
+                return item.state == HBJobStateWorking;
+            }];
+
+            if ([workingJobs containsObject:self.currentJob])
+            {
+                NSString *alertTitle = [NSString stringWithFormat:NSLocalizedString(@"Stop This Encode and Remove It?", nil)];
+
+                // Which window to attach the sheet to?
+                NSWindow *targetWindow = nil;
+                if ([sender respondsToSelector: @selector(window)])
+                {
+                    targetWindow = [sender window];
+                }
+
+                NSAlert *alert = [[NSAlert alloc] init];
+                [alert setMessageText:alertTitle];
+                [alert setInformativeText:NSLocalizedString(@"Your movie will be lost if you don't continue encoding.", nil)];
+                [alert addButtonWithTitle:NSLocalizedString(@"Keep Encoding", nil)];
+                [alert addButtonWithTitle:NSLocalizedString(@"Stop Encoding and Delete", nil)];
+                [alert setAlertStyle:NSCriticalAlertStyle];
+
+                [alert beginSheetModalForWindow:targetWindow
+                                  modalDelegate:self
+                                 didEndSelector:@selector(didDimissCancelCurrentJob:returnCode:contextInfo:)
+                                    contextInfo:NULL];
+            }
+        }
 
         // remove the non working items immediately
         [self removeQueueItemsAtIndexes:targetedRows];
         [self.outlineView endUpdates];
 
         [self.jobs commit];
-
-        if ([workingJobs containsObject:self.currentJob])
-        {
-            NSString *alertTitle = [NSString stringWithFormat:NSLocalizedString(@"Stop This Encode and Remove It?", nil)];
-
-            // Which window to attach the sheet to?
-            NSWindow *targetWindow = nil;
-            if ([sender respondsToSelector: @selector(window)])
-            {
-                targetWindow = [sender window];
-            }
-
-            NSAlert *alert = [[NSAlert alloc] init];
-            [alert setMessageText:alertTitle];
-            [alert setInformativeText:NSLocalizedString(@"Your movie will be lost if you don't continue encoding.", nil)];
-            [alert addButtonWithTitle:NSLocalizedString(@"Keep Encoding", nil)];
-            [alert addButtonWithTitle:NSLocalizedString(@"Stop Encoding and Delete", nil)];
-            [alert setAlertStyle:NSCriticalAlertStyle];
-
-            [alert beginSheetModalForWindow:targetWindow
-                              modalDelegate:self
-                             didEndSelector:@selector(didDimissCancelCurrentJob:returnCode:contextInfo:)
-                                contextInfo:NULL];
-        }
     }
 }