From 049184d253574fe59f987061781f441bceab4fc5 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sun, 20 Jul 2003 20:26:20 +0000 Subject: [PATCH] Corrected an issue with saving images/sounds git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@17267 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 +++++++++ GormDocument.m | 43 ++++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7181bc31..686ce37e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-07-20 Gregory John Casamento + + * GormDocument.m: (-[GormDocument saveGormDocument:]) added + code to prevent copying of images/sounds if the source path + is the same as the destination. This was causing the file + to be truncated to zero and caused Gorm to lock. + * (-[GormDocument parseHeader:]): removed + extra characterset definition/ + 2003-07-14 Gregory John Casamento * GormClassManager.[hm]: Added implementation for new methods diff --git a/GormDocument.m b/GormDocument.m index fbeac1e9..d15ba46c 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -183,7 +183,6 @@ static NSImage *classesImage = nil; [connections addObject: aConnector]; [nc postNotificationName: IBDidAddConnectorNotification object: aConnector]; - } } @@ -773,7 +772,6 @@ static NSImage *classesImage = nil; NSScanner *headerScanner = [NSScanner scannerWithString: headerFile]; GormClassManager *cm = [self classManager]; NSCharacterSet *superClassStopSet = [NSCharacterSet characterSetWithCharactersInString: @" \n"]; - NSCharacterSet *commentStopSet = [NSCharacterSet characterSetWithCharactersInString: @"\n"]; NSCharacterSet *classStopSet = [NSCharacterSet characterSetWithCharactersInString: @" :"]; NSCharacterSet *categoryStopSet = [NSCharacterSet characterSetWithCharactersInString: @" ("]; NSCharacterSet *typeStopSet = [NSCharacterSet characterSetWithCharactersInString: @" "]; @@ -784,6 +782,7 @@ static NSImage *classesImage = nil; NSArray *outletTokens = [NSArray arrayWithObjects: @"id", @"IBOutlet", nil]; NSArray *actionTokens = [NSArray arrayWithObjects: @"(void)", @"(IBAction)", @"(id)", nil]; NSRange notFoundRange = NSMakeRange(NSNotFound,0); + // NSCharacterSet *commentStopSet = [NSCharacterSet characterSetWithCharactersInString: @"\n"]; while (![headerScanner isAtEnd]) { @@ -2782,12 +2781,13 @@ static NSImage *classesImage = nil; // create the directory... archiveResult = [mgr createDirectoryAtPath: documentPath attributes: nil]; } + + RELEASE(archiver); // We're done with the archiver here.. if (archiveResult) { // save the data... archiveResult = [archiverData writeToFile: gormPath atomically: YES]; - RELEASE(archiver); if (archiveResult) { // save the custom classes.. and we're done... @@ -2802,13 +2802,21 @@ static NSImage *classesImage = nil; while ((object = [en nextObject]) != nil) { NSString *soundPath; - BOOL copied; + BOOL copied = NO; - soundPath = [documentPath stringByAppendingPathComponent: - [object lastPathComponent]]; - copied = [mgr copyPath: object - toPath: soundPath - handler: nil]; + if(![object isEqualToString: imagePath]) + { + soundPath = [documentPath stringByAppendingPathComponent: + [object lastPathComponent]]; + copied = [mgr copyPath: object + toPath: soundPath + handler: nil]; + } + else + { + // mark as copied if paths are equal... + copied = YES; + } if (!copied) { @@ -2821,13 +2829,22 @@ static NSImage *classesImage = nil; while ((object = [en nextObject]) != nil) { NSString *imagePath; - BOOL copied; + BOOL copied = NO; imagePath = [documentPath stringByAppendingPathComponent: [object lastPathComponent]]; - copied = [mgr copyPath: object - toPath: imagePath - handler: nil]; + + if(![object isEqualToString: imagePath]) + { + copied = [mgr copyPath: object + toPath: imagePath + handler: nil]; + } + else + { + // mark it as copied if paths are equal. + copied = YES; + } if (!copied) {