Revision: 4269
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4269&view=rev
Author:   hofman
Date:     2008-07-21 16:47:19 +0000 (Mon, 21 Jul 2008)

Log Message:
-----------
Import Foundation in headers used by tool. Catch exceptions raised by 
NSKeyedUnarchiver.

Modified Paths:
--------------
    trunk/SkimNotes/NSFileManager_SKNExtensions.m
    trunk/SkimNotes/NSFileManager_SKNToolExtensions.m
    trunk/SkimNotes/SKNUtilities.h
    trunk/SkimNotes/SKNUtilities.m
    trunk/SkimNotes/SkimNotes_Tool_Prefix.pch

Modified: trunk/SkimNotes/NSFileManager_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/NSFileManager_SKNExtensions.m       2008-07-21 13:00:32 UTC 
(rev 4268)
+++ trunk/SkimNotes/NSFileManager_SKNExtensions.m       2008-07-21 16:47:19 UTC 
(rev 4269)
@@ -99,10 +99,12 @@
     if ([aURL isFileURL]) {
         NSData *data = [[SKNExtendedAttributeManager sharedManager] 
extendedAttributeNamed:SKIM_NOTES_KEY atPath:[aURL path] traverseLink:YES 
error:&error];
         
-        if ([data length])
-            notes = [NSKeyedUnarchiver unarchiveObjectWithData:data];
-        else if (data || [error code] == ENOATTR)
+        if ([data length]) {
+            @try { notes = [NSKeyedUnarchiver unarchiveObjectWithData:data]; }
+            @catch (id e) {}
+        } else if (data || [error code] == ENOATTR) {
             notes = [NSArray array];
+        }
     }
     if (notes == nil && outError) 
         *outError = error ? error : [NSError 
errorWithDomain:NSPOSIXErrorDomain code:ENOENT userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKNLocalizedString(@"The file does not exist or is 
not a file.", @"Error description"), NSLocalizedDescriptionKey, nil]];
@@ -149,10 +151,12 @@
         NSString *skimFile = [self bundledFileWithExtension:SKIM_EXTENSION 
inPDFBundleAtPath:path error:&error];
         NSData *data = skimFile ? [NSData dataWithContentsOfFile:skimFile 
options:0 error:&error] : nil;
         
-        if ([data length])
-            notes = [NSKeyedUnarchiver unarchiveObjectWithData:data];
-        else if (data)
+        if ([data length]) {
+            @try { notes = [NSKeyedUnarchiver unarchiveObjectWithData:data]; }
+            @catch (id e) {}
+        } else if (data) {
             notes = [NSArray array];
+        }
     }
     if (notes == nil && outError) 
         *outError = error ? error : [NSError 
errorWithDomain:NSPOSIXErrorDomain code:ENOENT userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKNLocalizedString(@"The file does not exist or is 
not a package.", @"Error description"), NSLocalizedDescriptionKey, nil]];
@@ -207,10 +211,12 @@
     if ([aURL isFileURL] && [self fileExistsAtPath:path]) {
         NSData *data = [NSData dataWithContentsOfFile:path options:0 
error:&error];
         
-        if ([data length])
-            notes = [NSKeyedUnarchiver unarchiveObjectWithData:data];
-        else if (data)
+        if ([data length]) {
+            @try { notes = [NSKeyedUnarchiver unarchiveObjectWithData:data]; }
+            @catch (id e) {}
+        } else if (data) {
             notes = [NSArray array];
+        }
     }
     if (notes == nil && outError) 
         *outError = error ? error : [NSError 
errorWithDomain:NSPOSIXErrorDomain code:ENOENT userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKNLocalizedString(@"The file does not exist or is 
not a file.", @"Error description"), NSLocalizedDescriptionKey, nil]];

Modified: trunk/SkimNotes/NSFileManager_SKNToolExtensions.m
===================================================================
--- trunk/SkimNotes/NSFileManager_SKNToolExtensions.m   2008-07-21 13:00:32 UTC 
(rev 4268)
+++ trunk/SkimNotes/NSFileManager_SKNToolExtensions.m   2008-07-21 16:47:19 UTC 
(rev 4269)
@@ -154,7 +154,9 @@
     [self removeSkimNotesAtPath:path error:NULL];
     if ([notesData length]) {
         if (textNotes == nil || rtfNotesData == nil) {
-            NSArray *notes = [NSKeyedUnarchiver 
unarchiveObjectWithData:notesData];
+            NSArray *notes = nil;
+            @try { notes = [NSKeyedUnarchiver 
unarchiveObjectWithData:notesData]; }
+            @catch (id e) {}
             if ([notes count]) {
                 if (textNotes == nil)
                     textNotes = SKNTextNotes(notes);

Modified: trunk/SkimNotes/SKNUtilities.h
===================================================================
--- trunk/SkimNotes/SKNUtilities.h      2008-07-21 13:00:32 UTC (rev 4268)
+++ trunk/SkimNotes/SKNUtilities.h      2008-07-21 16:47:19 UTC (rev 4269)
@@ -36,7 +36,7 @@
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
 
 #define SKIM_NOTES_KEY      @"net_sourceforge_skim-app_notes"
 #define SKIM_RTF_NOTES_KEY  @"net_sourceforge_skim-app_rtf_notes"

Modified: trunk/SkimNotes/SKNUtilities.m
===================================================================
--- trunk/SkimNotes/SKNUtilities.m      2008-07-21 13:00:32 UTC (rev 4268)
+++ trunk/SkimNotes/SKNUtilities.m      2008-07-21 16:47:19 UTC (rev 4269)
@@ -37,6 +37,7 @@
  */
 
 #import "SKNUtilities.h"
+#import <AppKit/AppKit.h>
 
 #define NOTE_PAGE_INDEX_KEY @"pageIndex"
 #define NOTE_TYPE_KEY @"type"

Modified: trunk/SkimNotes/SkimNotes_Tool_Prefix.pch
===================================================================
--- trunk/SkimNotes/SkimNotes_Tool_Prefix.pch   2008-07-21 13:00:32 UTC (rev 
4268)
+++ trunk/SkimNotes/SkimNotes_Tool_Prefix.pch   2008-07-21 16:47:19 UTC (rev 
4269)
@@ -4,6 +4,7 @@
 
 #ifdef __OBJC__
     #import <Foundation/Foundation.h>
+    #import <AppKit/AppKit.h>
     
     #if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MAX_ALLOWED < 
MAC_OS_X_VERSION_10_5
     #import "SKNCompatibility.h"


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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to