Revision: 22676
          http://sourceforge.net/p/bibdesk/svn/22676
Author:   hofman
Date:     2018-09-26 14:33:02 +0000 (Wed, 26 Sep 2018)
Log Message:
-----------
Only can have invalid container when passing a collection to remove command

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

Modified: trunk/bibdesk/BDSKRemoveCommand.m
===================================================================
--- trunk/bibdesk/BDSKRemoveCommand.m   2018-09-26 14:11:41 UTC (rev 22675)
+++ trunk/bibdesk/BDSKRemoveCommand.m   2018-09-26 14:33:02 UTC (rev 22676)
@@ -124,10 +124,19 @@
                 }
             }
             
-            if (containerSpecifier && removeKey == nil) {
+            if (removeKey == nil) {
                 if ([containerSpecifier isKindOfClass:[NSPropertySpecifier 
class]]) {
                     removeContainer = [[containerSpecifier containerSpecifier] 
objectsByEvaluatingSpecifier];
                     removeKey = [containerSpecifier key];
+                    containerClassDescription = [removeContainer 
scriptClassDescription];
+                    // see if it is a valid property to remove the objects from
+                    if (removeContainer && removeKey &&
+                        ([[containerClassDescription toManyRelationshipKeys] 
containsObject:removeKey] == NO ||
+                         [containerClassDescription 
hasWritablePropertyForKey:removeKey] == NO ||
+                         [removeClassDescription 
isKindOfClassDescription:[containerClassDescription 
classDescriptionForKey:removeKey]] == NO)) {
+                        [self 
setScriptErrorNumber:NSArgumentsWrongScriptError];
+                        [self setScriptErrorString:NSLocalizedString(@"Invalid 
container to remove from", @"Error description")];
+                    }
                 } else if (containerSpecifier) {
                     removeContainer = [containerSpecifier 
objectsByEvaluatingSpecifier];
                     // make sure this is a valid object, so not something like 
a range specifier
@@ -147,19 +156,14 @@
             }
             
             // check if the remove location is valid
-            if (containerClassDescription == nil && removeContainer)
-                containerClassDescription = [removeContainer 
scriptClassDescription];
-            if (removeContainer == nil || removeKey == nil ||
-                [[containerClassDescription toManyRelationshipKeys] 
containsObject:removeKey] == NO) {
-                [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-                [self setScriptErrorString:NSLocalizedString(@"Could not find 
container to remove from", @"Error description")];
-            } else if ([containerClassDescription 
hasWritablePropertyForKey:removeKey] == NO ||
-                       [removeClassDescription 
isKindOfClassDescription:[containerClassDescription 
classDescriptionForKey:removeKey]] == NO) {
-                [self setScriptErrorNumber:NSArgumentsWrongScriptError];
-                [self setScriptErrorString:NSLocalizedString(@"Invalid 
container to remove from", @"Error description")];
-            } else {
-                // remove using KVC, I don't know how to use scripting KVC as 
I don't know how to get the indexes in general
-                [[removeContainer mutableArrayValueForKey:removeKey] 
removeObjectsInArray:removeObjects];
+            if ([self scriptErrorNumber] == NSNoScriptError) {
+                if (removeContainer == nil || removeKey == nil) {
+                    [self setScriptErrorNumber:NSArgumentsWrongScriptError];
+                    [self setScriptErrorString:NSLocalizedString(@"Could not 
find container to remove from", @"Error description")];
+                } else {
+                    // remove using KVC, I don't know how to use scripting KVC 
as I don't know how to get the indexes in general
+                    [[removeContainer mutableArrayValueForKey:removeKey] 
removeObjectsInArray:removeObjects];
+                }
             }
         }
     }

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



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to