From: <ama...@us...> - 2006-09-23 17:07:06
|
Revision: 7747 http://svn.sourceforge.net/bibdesk/?rev=7747&view=rev Author: amaxwell Date: 2006-09-23 10:06:53 -0700 (Sat, 23 Sep 2006) Log Message: ----------- Fix crasher when TeXification fails on 10.4; NSDocumentController tries to display a garbage NSError when writeToURL:ofType:error: returns NO, so we explicitly set it to nil (since we display our own alert sheet). Modified Paths: -------------- trunk/bibdesk/BibDocument.m Modified: trunk/bibdesk/BibDocument.m =================================================================== --- trunk/bibdesk/BibDocument.m 2006-09-23 13:58:26 UTC (rev 7746) +++ trunk/bibdesk/BibDocument.m 2006-09-23 17:06:53 UTC (rev 7747) @@ -782,11 +782,15 @@ *outError = nsError; } @catch(id exception){ + if([exception isKindOfClass:[NSException class]] && [[exception name] isEqualToString:BDSKTeXifyException]){ success = NO; error = [exception reason]; if([[exception userInfo] valueForKey:@"item"]) - [self highlightBib:[[exception userInfo] valueForKey:@"item"]]; + [self highlightBib:[[exception userInfo] valueForKey:@"item"]]; + + // NSDocumentController will crash if we don't set this to nil when returning NO + *outError = nil; } else { @throw; } @@ -796,6 +800,8 @@ if(success && currentSaveOperationType != 3) [self performSelector:@selector(clearChangeCount) withObject:nil afterDelay:0.01]; else if(error != nil){ + + // @@ 10.3: we run a sheet so this is displayed on 10.3, but could convert to using NSError on 10.4 NSString *errTitle = currentSaveOperationType == 3 ? NSLocalizedString(@"Unable to Autosave File", @"") : NSLocalizedString(@"Unable to Save File", @""); NSString *errMsg = [NSString stringWithFormat:@"%@ %@", error, NSLocalizedString(@"If you are unable to fix this item, you must disable character conversion in BibDesk's preferences and save your file in an encoding such as UTF-8.", @"")]; // log in case the sheet crashes us for some reason @@ -804,8 +810,8 @@ NSBeginCriticalAlertSheet(errTitle, nil, nil, nil, documentWindow, nil, NULL, NULL, NULL, errMsg); } - // rebuild metadata cache for this document whenever we save - if(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_3 && [self fileURL]){ + // rebuild metadata cache for this document whenever we save successfully + if(success && floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_3 && [self fileURL]){ NSEnumerator *pubsE = [[self publications] objectEnumerator]; NSMutableArray *pubsInfo = [[NSMutableArray alloc] initWithCapacity:[publications count]]; BibItem *anItem; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |