From 0c96d0e0afec6fc9078158ba32811e06349a8315 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Thu, 15 Dec 2005 03:12:26 +0000 Subject: [PATCH] Correction for bug#15178 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@22168 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Gorm.m | 26 ++++++++++++++------------ GormCore/GormDocument.h | 5 +++++ GormCore/GormDocument.m | 20 ++++++++------------ 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index e831295c..860a9a89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-12-14 22:08 Gregory John Casamento + + * GormCore/GormDocument.h: Declaration for new readableTypes method. + * GormCore/GormDocument.m: Added readableTypes method to return the + types accepted by GormDocument. + * Gorm.m: Use readableTypes in application:openFile: corrects + bug#15178 + 2005-11-19 09:57 Gregory John Casamento * Version 1.0.1 diff --git a/Gorm.m b/Gorm.m index a76a1c6c..d63bc3a1 100644 --- a/Gorm.m +++ b/Gorm.m @@ -1077,22 +1077,24 @@ return nil; } - - - (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName { - GormDocument *doc = AUTORELEASE([[GormDocument alloc] init]); + NSString *ext = [fileName pathExtension]; + GormDocument *doc = nil; - [documents addObject: doc]; - if ([doc loadDocument: fileName] == nil) + if([[GormDocument readableTypes] containsObject: ext]) { - [documents removeObjectIdenticalTo: doc]; - doc = nil; - } - else - { - [[doc window] orderFrontRegardless]; - [[doc window] makeKeyWindow]; + doc = AUTORELEASE([[GormDocument alloc] init]); + if ([doc loadDocument: fileName] == nil) + { + doc = nil; + } + else + { + [documents addObject: doc]; + [[doc window] orderFrontRegardless]; + [[doc window] makeKeyWindow]; + } } return (doc != nil); diff --git a/GormCore/GormDocument.h b/GormCore/GormDocument.h index aacf27fc..f06e5b4f 100644 --- a/GormCore/GormDocument.h +++ b/GormCore/GormDocument.h @@ -77,6 +77,11 @@ NSMutableArray *resourceManagers; } +/** + * Return the types readable by this document class + */ ++ (NSArray *) readableTypes; + /* Archiving objects */ /** diff --git a/GormCore/GormDocument.m b/GormCore/GormDocument.m index 7dd2705c..49306a10 100644 --- a/GormCore/GormDocument.m +++ b/GormCore/GormDocument.m @@ -200,6 +200,14 @@ static NSImage *fileImage = nil; } } +/** + * Return the types readable by this document class. + */ ++ (NSArray *) readableTypes +{ + return [NSArray arrayWithObjects: @"gorm", @"gmodel", nil]; +} + /** * Initialize the new GormDocument object. */ @@ -1681,7 +1689,6 @@ static NSImage *fileImage = nil; [editors addObjectsFromArray: openEditors]; [editors makeObjectsPerformSelector: @selector(close)]; [openEditors removeAllObjects]; - // [editors makeObjectsPerformSelector: @selector(release)]; [editors removeAllObjects]; // Close the editors in the document window... @@ -1710,19 +1717,8 @@ static NSImage *fileImage = nil; enumerator = [nameTable objectEnumerator]; while ((obj = [enumerator nextObject]) != nil) { - /* - if ([obj isKindOfClass: [NSMenu class]] == YES) - { - if ([[obj window] isVisible] == YES) - { - [obj close]; - } - } - else - */ if ([obj isKindOfClass: [NSWindow class]] == YES) { - // [obj setReleasedWhenClosed: YES]; [obj close]; RELEASE(obj); }