diff options
author | dynaflash <[email protected]> | 2010-07-22 16:12:55 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2010-07-22 16:12:55 +0000 |
commit | 925dfe6a2292889fd623d4092747ad798b5d1606 (patch) | |
tree | bc04118f03d1515b0f7b0268102a92cea0be672e | |
parent | 994b648e3ea1d42951221b9cdb0d2b5f4310b652 (diff) |
MacGui: Fix issue where queue was being reloaded showing already completed encodes at launch. Borked in svn rev 3443.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3453 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | macosx/Controller.m | 86 |
1 files changed, 57 insertions, 29 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index d9122b587..47303dfc9 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -182,9 +182,9 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It */ if (hbInstanceNum > 1) { - alertTitle = [NSString stringWithFormat: - NSLocalizedString(@"There is already an instance of HandBrake running.", @"")]; - NSBeginCriticalAlertSheet( + alertTitle = [NSString stringWithFormat: + NSLocalizedString(@"There is already an instance of HandBrake running.", @"")]; + NSBeginCriticalAlertSheet( alertTitle, NSLocalizedString(@"Reload Queue", nil), nil, @@ -195,29 +195,48 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It } else { - if (fWorkingCount > 0) + if (fWorkingCount > 0 || fPendingCount > 0) { - alertTitle = [NSString stringWithFormat: - NSLocalizedString(@"HandBrake Has Detected %d Previously Encoding Item and %d Pending Item(s) In Your Queue.", @""), - fWorkingCount,fPendingCount]; + if (fWorkingCount > 0) + { + alertTitle = [NSString stringWithFormat: + NSLocalizedString(@"HandBrake Has Detected %d Previously Encoding Item(s) and %d Pending Item(s) In Your Queue.", @""), + fWorkingCount,fPendingCount]; + } + else + { + alertTitle = [NSString stringWithFormat: + NSLocalizedString(@"HandBrake Has Detected %d Pending Item(s) In Your Queue.", @""), + fPendingCount]; + } + + NSBeginCriticalAlertSheet( + alertTitle, + NSLocalizedString(@"Reload Queue", nil), + nil, + NSLocalizedString(@"Empty Queue", nil), + fWindow, self, + nil, @selector(didDimissReloadQueue:returnCode:contextInfo:), nil, + NSLocalizedString(@" Do you want to reload them ?", nil)); } else { - alertTitle = [NSString stringWithFormat: - NSLocalizedString(@"HandBrake Has Detected %d Pending Item(s) In Your Queue.", @""), - fPendingCount]; + /* Since we addressed any pending or previously encoding items above, we go ahead and make sure the queue + * is empty of any finished items or cancelled items */ + [self clearQueueAllItems]; + /* We show whichever open source window specified in LaunchSourceBehavior preference key */ + if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source"]) + { + [self browseSources:nil]; + } + + if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source (Title Specific)"]) + { + [self browseSources:(id)fOpenSourceTitleMMenu]; + } } - NSBeginCriticalAlertSheet( - alertTitle, - NSLocalizedString(@"Reload Queue", nil), - nil, - NSLocalizedString(@"Empty Queue", nil), - fWindow, self, - nil, @selector(didDimissReloadQueue:returnCode:contextInfo:), nil, - NSLocalizedString(@" Do you want to reload them ?", nil)); } - } else { @@ -255,7 +274,6 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It { if ([[runningAppsDictionary valueForKey:@"NSApplicationName"] isEqualToString:@"HandBrake"]) { - hbInstances++; /*Report the path to each active instances app path */ runningInstancePidNum = [[runningAppsDictionary valueForKey:@"NSApplicationProcessIdentifier"] intValue]; runningInstanceAppPath = [runningAppsDictionary valueForKey:@"NSApplicationPath"]; @@ -272,7 +290,8 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* Tell fQueueController what our pidNum is */ [fQueueController setPidNum:pidNum]; } - } + hbInstances++; + } } return hbInstances; } @@ -281,8 +300,11 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It - (void) didDimissReloadQueue: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo { + + [self writeToActivityLog: "didDimissReloadQueue number of hb instances:%d", hbInstanceNum]; if (returnCode == NSAlertOtherReturn) { + [self writeToActivityLog: "didDimissReloadQueue NSAlertOtherReturn Chosen"]; [self clearQueueAllItems]; /* We show whichever open source window specified in LaunchSourceBehavior preference key */ @@ -298,8 +320,10 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It } else { - if ([self hbInstances] == 1) + [self writeToActivityLog: "didDimissReloadQueue First Button Chosen"]; + if (hbInstanceNum == 1) { + [self setQueueEncodingItemsAsPending]; } [self showQueueWindow:NULL]; @@ -2081,15 +2105,19 @@ fWorkingCount = 0; /* we look here to see if the preset is we move on to the next one */ while ( tempObject = [enumerator nextObject] ) { - /* If the queue item is marked as "encoding" (1) - * then change its status back to pending (2) which effectively - * puts it back into the queue to be encoded - */ - if ([[tempObject objectForKey:@"Status"] intValue] == 1) + /* We want to keep any queue item that is pending or was previously being encoded */ + if ([[tempObject objectForKey:@"Status"] intValue] == 1 || [[tempObject objectForKey:@"Status"] intValue] == 2) { - [tempObject setObject:[NSNumber numberWithInt: 2] forKey:@"Status"]; + /* If the queue item is marked as "encoding" (1) + * then change its status back to pending (2) which effectively + * puts it back into the queue to be encoded + */ + if ([[tempObject objectForKey:@"Status"] intValue] == 1) + { + [tempObject setObject:[NSNumber numberWithInt: 2] forKey:@"Status"]; + } + [tempArray addObject:tempObject]; } - [tempArray addObject:tempObject]; } [QueueFileArray setArray:tempArray]; |