Revision: 7094 http://skim-app.svn.sourceforge.net/skim-app/?rev=7094&view=rev Author: hofman Date: 2011-02-10 17:49:19 +0000 (Thu, 10 Feb 2011)
Log Message: ----------- don't open multiple notes documents for the same pdf Modified Paths: -------------- trunk/SKDocumentController.m Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2011-02-10 16:13:06 UTC (rev 7093) +++ trunk/SKDocumentController.m 2011-02-10 17:49:19 UTC (rev 7094) @@ -280,27 +280,36 @@ if ([[SKNotesDocument readableTypes] containsObject:type]) { document = [self openDocumentWithContentsOfURL:theURL display:YES error:outError]; - } else { - NSData *data = nil; - if ([type isEqualToString:SKPDFBundleDocumentType]) { - NSString *skimFile = [[NSFileManager defaultManager] bundledFileWithExtension:@"skim" inPDFBundleAtPath:[theURL path] error:&error]; - data = skimFile ? [NSData dataWithContentsOfFile:skimFile options:0 error:&error] : nil; - } else if ([[SKMainDocument readableTypes] containsObject:type]) { - data = [[SKNExtendedAttributeManager sharedManager] extendedAttributeNamed:SKIM_NOTES_KEY atPath:[theURL path] traverseLink:YES error:&error]; + } else if ([[SKMainDocument readableTypes] containsObject:type]) { + for (document in [self documents]) { + if ([document respondsToSelector:@selector(sourceFileURL)] && [[document sourceFileURL] isEqual:theURL]) + break; } - - if (data) - document = [self makeUntitledDocumentOfType:SKNotesDocumentType error:&error]; - - if ([document readFromData:data ofType:SKNotesDocumentType error:&error]) { - [self addDocument:document]; - [document setSourceFileURL:theURL]; - [document makeWindowControllers]; + if (document) { [document showWindows]; } else { - document = nil; - if (outError) - *outError = error; + NSData *data = nil; + + if ([type isEqualToString:SKPDFBundleDocumentType]) { + NSString *skimFile = [[NSFileManager defaultManager] bundledFileWithExtension:@"skim" inPDFBundleAtPath:[theURL path] error:&error]; + data = skimFile ? [NSData dataWithContentsOfFile:skimFile options:0 error:&error] : nil; + } else { + data = [[SKNExtendedAttributeManager sharedManager] extendedAttributeNamed:SKIM_NOTES_KEY atPath:[theURL path] traverseLink:YES error:&error]; + } + + if (data) + document = [self makeUntitledDocumentOfType:SKNotesDocumentType error:&error]; + + if ([document readFromData:data ofType:SKNotesDocumentType error:&error]) { + [self addDocument:document]; + [document setSourceFileURL:theURL]; + [document makeWindowControllers]; + [document showWindows]; + } else { + document = nil; + if (outError) + *outError = error; + } } } } else if (outError) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit