summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-03-02 18:06:21 +0100
committerDamiano Galassi <[email protected]>2017-03-02 18:06:21 +0100
commit5a85a7012b5cdf9bf7bf7733db01aeea087af596 (patch)
treec271336811d84253b4aa68e8e7b3f7d7e2379141 /macosx
parenta7d96f24f2c8df6b1092d4376c436e6d63514bdb (diff)
MacGui: do not remove a job from the queue if the rescan to the main window fails.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/HBController.h4
-rw-r--r--macosx/HBController.m74
-rw-r--r--macosx/HBJob.m3
-rw-r--r--macosx/HBQueueController.m25
4 files changed, 63 insertions, 43 deletions
diff --git a/macosx/HBController.h b/macosx/HBController.h
index 5385c914b..66fa4661c 100644
--- a/macosx/HBController.h
+++ b/macosx/HBController.h
@@ -17,8 +17,8 @@
- (void)launchAction;
-- (BOOL)openURL:(NSURL *)fileURL;
-- (BOOL)openJob:(HBJob *)job;
+- (void)openURL:(NSURL *)fileURL;
+- (void)openJob:(HBJob *)job completionHandler:(void (^)(BOOL result))handler;
- (IBAction)browseSources:(id)sender;
diff --git a/macosx/HBController.m b/macosx/HBController.m
index fa57e1141..5cb51da8b 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -621,81 +621,93 @@
self.window.representedURL = mediaURL;
self.window.title = mediaURL.lastPathComponent;
-
- completionHandler(self.core.titles);
}
else
{
// We display a message if a valid source was not chosen
fSrcDVD2Field.stringValue = NSLocalizedString(@"No Valid Source Found", @"");
}
+
+ completionHandler(self.core.titles);
[self.window.toolbar validateVisibleItems];
}];
}
+ else
+ {
+ completionHandler(@[]);
+ }
}
- (void)openURL:(NSURL *)fileURL titleIndex:(NSUInteger)index
{
[self scanURL:fileURL titleIndex:index completionHandler:^(NSArray<HBTitle *> *titles)
{
- [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:fileURL];
-
- HBTitle *featuredTitle = titles.firstObject;
- for (HBTitle *title in titles)
+ if (titles.count)
{
- if (title.isFeatured)
+ [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:fileURL];
+
+ HBTitle *featuredTitle = titles.firstObject;
+ for (HBTitle *title in titles)
{
- featuredTitle = title;
+ if (title.isFeatured)
+ {
+ featuredTitle = title;
+ }
}
- }
- HBJob *job = [self jobFromTitle:featuredTitle];
- self.job = job;
+ HBJob *job = [self jobFromTitle:featuredTitle];
+ self.job = job;
+ }
}];
}
-- (BOOL)openURL:(NSURL *)fileURL
+- (void)openURL:(NSURL *)fileURL
{
if (self.core.state != HBStateScanning)
{
[self openURL:fileURL titleIndex:0];
- return YES;
}
- return NO;
}
/**
* Rescans the a job back into the main window
*/
-- (BOOL)openJob:(HBJob *)job
+- (void)openJob:(HBJob *)job completionHandler:(void (^)(BOOL result))handler
{
if (self.core.state != HBStateScanning)
{
[self scanURL:job.fileURL titleIndex:job.titleIdx completionHandler:^(NSArray<HBTitle *> *titles)
{
- // If the scan was cached, reselect
- // the original title
- for (HBTitle *title in titles)
+ if (titles.count)
{
- if (title.index == job.titleIdx)
+ // If the scan was cached, reselect
+ // the original title
+ for (HBTitle *title in titles)
{
- job.title = title;
- break;
+ if (title.index == job.titleIdx)
+ {
+ job.title = title;
+ break;
+ }
}
- }
- // Else just one title or a title specific rescan
- // select the first title
- if (!job.title)
- {
- job.title = titles.firstObject;
+ // Else just one title or a title specific rescan
+ // select the first title
+ if (!job.title)
+ {
+ job.title = titles.firstObject;
+ }
+ self.job = job;
+
+ handler(YES);
}
- self.job = job;
+ handler(NO);
}];
-
- return YES;
}
- return NO;
+ else
+ {
+ handler(NO);
+ }
}
- (HBJob *)jobFromTitle:(HBTitle *)title
diff --git a/macosx/HBJob.m b/macosx/HBJob.m
index 7db980938..5631c9006 100644
--- a/macosx/HBJob.m
+++ b/macosx/HBJob.m
@@ -382,7 +382,8 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification";
{
_fileURL = [HBUtilities URLFromBookmark:_fileURLBookmark];
}
- else
+
+ if (!_fileURL)
{
decodeObject(_fileURL, NSURL);
}
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m
index 8ff546176..9219458ae 100644
--- a/macosx/HBQueueController.m
+++ b/macosx/HBQueueController.m
@@ -1270,16 +1270,23 @@
NSInteger index = [self.jobs indexOfObject:job];
- // Cancel the encode if it's the current item
- if (job == self.currentJob)
+ if (job != self.currentJob)
{
- [self cancelCurrentJobAndContinue];
- }
-
- if ([self.controller openJob:job])
- {
- // Now that source is loaded and settings applied, delete the queue item from the queue
- [self removeQueueItemAtIndex:index];
+ job.state = HBJobStateWorking;
+ [self.controller openJob:job completionHandler:^(BOOL result) {
+ [self.jobs beginTransaction];
+ if (result)
+ {
+ // Now that source is loaded and settings applied, delete the queue item from the queue
+ [self removeQueueItemAtIndex:index];
+ }
+ else
+ {
+ job.state = HBJobStateFailed;
+ NSBeep();
+ }
+ [self.jobs commit];
+ }];
}
else
{