diff options
-rw-r--r-- | macosx/English.lproj/MainWindow.xib | 6 | ||||
-rw-r--r-- | macosx/HBController.m | 16 | ||||
-rw-r--r-- | macosx/HBJob.m | 19 |
3 files changed, 34 insertions, 7 deletions
diff --git a/macosx/English.lproj/MainWindow.xib b/macosx/English.lproj/MainWindow.xib index 56715f1f1..52a7e2093 100644 --- a/macosx/English.lproj/MainWindow.xib +++ b/macosx/English.lproj/MainWindow.xib @@ -235,7 +235,11 @@ <string key="NSValueTransformerName">NSIsNotNil</string> </dictionary> </binding> - <binding destination="-2" name="value" keyPath="self.job.outputFileName" id="NAL-fw-AF5"/> + <binding destination="-2" name="value" keyPath="self.job.outputFileName" id="SgW-Bn-bwW"> + <dictionary key="options"> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <textField hidden="YES" toolTip="First second to encode." verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="5491"> diff --git a/macosx/HBController.m b/macosx/HBController.m index 83dcc9572..5c255789b 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -1117,9 +1117,11 @@ */ - (IBAction)addToQueue:(id)sender { - [self.window HB_endEditing]; - [self runDestinationAlerts:self.job - didEndSelector:@selector(overwriteAddToQueueAlertDone:returnCode:contextInfo:)]; + if ([self.window HB_endEditing]) + { + [self runDestinationAlerts:self.job + didEndSelector:@selector(overwriteAddToQueueAlertDone:returnCode:contextInfo:)]; + } } /** @@ -1166,9 +1168,11 @@ } else { - [self.window HB_endEditing]; - [self runDestinationAlerts:self.job - didEndSelector:@selector(overWriteAlertDone:returnCode:contextInfo:)]; + if ([self.window HB_endEditing]) + { + [self runDestinationAlerts:self.job + didEndSelector:@selector(overWriteAlertDone:returnCode:contextInfo:)]; + } } } diff --git a/macosx/HBJob.m b/macosx/HBJob.m index 8c672445e..d90d95be0 100644 --- a/macosx/HBJob.m +++ b/macosx/HBJob.m @@ -166,6 +166,25 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; _outputFileName = [outputFileName copy]; } +- (BOOL)validateOutputFileName:(id *)ioValue error:(NSError * __autoreleasing *)outError +{ + BOOL retval = YES; + + if (nil != *ioValue) + { + NSString *value = *ioValue; + + if ([value rangeOfString:@"/"].location != NSNotFound) + { + *outError = [NSError errorWithDomain:@"HBError" code:0 userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid name", nil), + NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString(@"The file name can't contain the / character.", nil)}]; + return NO; + } + } + + return retval; +} + - (NSURL *)completeOutputURL { return [self.outputURL URLByAppendingPathComponent:self.outputFileName]; |