summaryrefslogtreecommitdiffstats
path: root/macosx/HBQueueController.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-07-22 12:02:56 +0000
committerritsuka <[email protected]>2015-07-22 12:02:56 +0000
commita52eac98fc00823cae072b7a6fc53fa0399450a9 (patch)
treef317ffbc16882a5a5c58c212975a968329dd5d1d /macosx/HBQueueController.m
parent438ffd01fdc4615aab516394d7eb422f7ca3af3f (diff)
MacGui: fix an issue where the the user was already asked if he wanted to delete the working job.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7360 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBQueueController.m')
-rw-r--r--macosx/HBQueueController.m60
1 files changed, 32 insertions, 28 deletions
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m
index d43c43d70..c366ce14e 100644
--- a/macosx/HBQueueController.m
+++ b/macosx/HBQueueController.m
@@ -726,17 +726,45 @@
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];
@@ -747,30 +775,6 @@
[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];
- }
}
}