Revision: 11393
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11393&view=rev
Author:   hofman
Date:     2007-10-26 02:46:21 -0700 (Fri, 26 Oct 2007)

Log Message:
-----------
Extend update method to update invalid fsref.

Modified Paths:
--------------
    branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFile.m

Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFile.m
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFile.m  2007-10-25 21:29:49 UTC 
(rev 11392)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFile.m  2007-10-26 09:46:21 UTC 
(rev 11393)
@@ -499,23 +499,35 @@
 
 // Should we implement -isEqual: and -hash?
 
+// this could be called when the document fileURL changes
 - (void)update {
     NSURL *baseURL = [delegate baseURLForAliasFile:self];
     FSRef baseRef;
+    
     if (fileRef == NULL) {
         // this does the updating if possible
         [self fileRef];
-    } else if (baseURL && CFURLGetFSRef((CFURLRef)baseURL, &baseRef)) {
-        Boolean didUpdate;
-        if (alias)
-            FSUpdateAlias(&baseRef, fileRef, [alias alias], &didUpdate);
-        else
-            alias = [[BDAlias alloc] initWithFSRef:(FSRef *)fileRef 
relativeToFSRef:&baseRef];
-        if (baseURL) {
-            CFURLRef tmpURL = CFURLCreateFromFSRef(CFAllocatorGetDefault(), 
fileRef);
-            if (tmpURL) {
-                [self setRelativePath:[[baseURL path] 
relativePathToFilename:[(NSURL *)tmpURL path]]];
-                CFRelease(tmpURL);
+    } else {
+        CFURLRef aURL = CFURLCreateFromFSRef(CFAllocatorGetDefault(), aRef);
+        if (aURL == NULL) {
+            // the fileRef was invalid, reset it and update
+            [self setFileRef:NULL];
+            [self fileRef];
+        } else {
+            CFRelease(aURL);
+            if (baseURL && CFURLGetFSRef((CFURLRef)baseURL, &baseRef)) {
+                Boolean didUpdate;
+                if (alias)
+                    FSUpdateAlias(&baseRef, fileRef, [alias alias], 
&didUpdate);
+                else
+                    alias = [[BDAlias alloc] initWithFSRef:(FSRef *)fileRef 
relativeToFSRef:&baseRef];
+                if (baseURL) {
+                    CFURLRef tmpURL = 
CFURLCreateFromFSRef(CFAllocatorGetDefault(), fileRef);
+                    if (tmpURL) {
+                        [self setRelativePath:[[baseURL path] 
relativePathToFilename:[(NSURL *)tmpURL path]]];
+                        CFRelease(tmpURL);
+                    }
+                }
             }
         }
     }


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to