diff options
author | Damiano Galassi <[email protected]> | 2015-09-30 07:47:00 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2015-09-30 07:47:00 +0200 |
commit | c667e5ae33ce3cb13d24925fe63e1e286192af5f (patch) | |
tree | 2b235c208c8ff36709bd30e92d30ec96a59b42f1 /macosx/HBCore.m | |
parent | c5360d65dfec773d87735b6db0d012df4045bd04 (diff) |
MacGui: add a way to differentiate a cancelled scan/encoded from a failed scan/encode
Diffstat (limited to 'macosx/HBCore.m')
-rw-r--r-- | macosx/HBCore.m | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/macosx/HBCore.m b/macosx/HBCore.m index 7acbf3490..c6925abbf 100644 --- a/macosx/HBCore.m +++ b/macosx/HBCore.m @@ -501,15 +501,24 @@ static void hb_error_handler(const char *errmsg) // Call the completion block and clean ups the handlers self.progressHandler = nil; + + HBCoreResult result = HBCoreResultDone; if (_hb_state->state == HB_STATE_WORKDONE) { - [self handleWorkCompletion]; + result = [self workDone] ? HBCoreResultDone : HBCoreResultFailed; } else { - [self handleScanCompletion]; + result = [self scanDone] ? HBCoreResultDone : HBCoreResultFailed; + } + + if (self.isCancelled) + { + result = HBCoreResultCancelled; } + [self runCompletionBlockAndCleanUpWithResult:result]; + // Reset the cancelled state. self.cancelled = NO; } @@ -519,7 +528,7 @@ static void hb_error_handler(const char *errmsg) * * @param result the result to pass to the completion block. */ -- (void)runCompletionBlockAndCleanUpWithResult:(BOOL)result +- (void)runCompletionBlockAndCleanUpWithResult:(HBCoreResult)result { if (self.completionHandler) { @@ -531,22 +540,4 @@ static void hb_error_handler(const char *errmsg) } } -/** - * Processes scan completion. - */ -- (void)handleScanCompletion -{ - BOOL result = [self scanDone]; - [self runCompletionBlockAndCleanUpWithResult:result]; -} - -/** - * Processes work completion. - */ -- (void)handleWorkCompletion -{ - BOOL result = [self workDone]; - [self runCompletionBlockAndCleanUpWithResult:result]; -} - @end |