Revision: 29288
          http://sourceforge.net/p/bibdesk/svn/29288
Author:   hofman
Date:     2025-07-17 21:21:34 +0000 (Thu, 17 Jul 2025)
Log Message:
-----------
write validation directly inline without variabble

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.m

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2025-07-17 21:09:41 UTC (rev 29287)
+++ trunk/bibdesk/BDSKEditor.m  2025-07-17 21:21:34 UTC (rev 29288)
@@ -477,37 +477,18 @@
         
         if (textField) {
             
-            BOOL valid = YES;
-            NSString *obj = nil;
+            NSString *string = [textView string];
+            NSString *obj = string;
             NSFormatter *formatter = [textField formatter];
             
             if (formatter) {
                 NSString *errorString = nil;
-                NSString *string = [textView string];
-                valid = [formatter getObjectValue:&obj forString:string 
errorDescription:&errorString];
-                if (valid == NO) {
-                    valid = [self control:textField 
didFailToFormatString:string errorDescription:errorString error:error];
-                    if (valid == NO)
-                        return NO;
-                }
-            } else {
-                obj = [textView string];
+                if (NO == [formatter getObjectValue:&obj forString:string 
errorDescription:&errorString] &&
+                    NO == [self control:textField didFailToFormatString:string 
errorDescription:errorString error:error])
+                    return NO;
             }
-            valid = [self control:textField isValidObject:obj error:error];
-            
-            if (valid == NO) {
-                if (error && [*error localizedRecoveryOptions]) {
-                    // no recovery possible, so just make it an unrecoverable 
error
-                    NSError *err = [NSError 
mutableLocalErrorWithCode:kBDSKFailedToCommit localizedDescription:[*error 
localizedDescription]];
-                    NSString *errString = [*error localizedRecoverySuggestion];
-                    NSRange r = [errString rangeOfString:@"."];
-                    if (r.location != NSNotFound)
-                        errString = [errString substringToIndex:NSMaxRange(r)];
-                    [err setValue:errString 
forKey:NSLocalizedRecoverySuggestionErrorKey];
-                    *error = err;
-                }
+            if (NO == [self control:textField isValidObject:obj error:error])
                 return NO;
-            }
             
         } else if (currentEditedView && [self validateCurrentEditedView] == 
NO) {
             // the string of the edited textView has unbalanced braces

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to