Correction for bug#15178

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@22168 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-12-15 03:12:26 +00:00
parent 97532b8646
commit 0c96d0e0af
4 changed files with 35 additions and 24 deletions

View file

@ -1,3 +1,11 @@
2005-12-14 22:08 Gregory John Casamento <greg_casamento@yahoo.com>
* 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 <greg_casamento@yahoo.com> 2005-11-19 09:57 Gregory John Casamento <greg_casamento@yahoo.com>
* Version 1.0.1 * Version 1.0.1

26
Gorm.m
View file

@ -1077,22 +1077,24 @@
return nil; return nil;
} }
- (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName - (BOOL)application:(NSApplication *)application openFile:(NSString *)fileName
{ {
GormDocument *doc = AUTORELEASE([[GormDocument alloc] init]); NSString *ext = [fileName pathExtension];
GormDocument *doc = nil;
[documents addObject: doc]; if([[GormDocument readableTypes] containsObject: ext])
if ([doc loadDocument: fileName] == nil)
{ {
[documents removeObjectIdenticalTo: doc]; doc = AUTORELEASE([[GormDocument alloc] init]);
doc = nil; if ([doc loadDocument: fileName] == nil)
} {
else doc = nil;
{ }
[[doc window] orderFrontRegardless]; else
[[doc window] makeKeyWindow]; {
[documents addObject: doc];
[[doc window] orderFrontRegardless];
[[doc window] makeKeyWindow];
}
} }
return (doc != nil); return (doc != nil);

View file

@ -77,6 +77,11 @@
NSMutableArray *resourceManagers; NSMutableArray *resourceManagers;
} }
/**
* Return the types readable by this document class
*/
+ (NSArray *) readableTypes;
/* Archiving objects */ /* Archiving objects */
/** /**

View file

@ -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. * Initialize the new GormDocument object.
*/ */
@ -1681,7 +1689,6 @@ static NSImage *fileImage = nil;
[editors addObjectsFromArray: openEditors]; [editors addObjectsFromArray: openEditors];
[editors makeObjectsPerformSelector: @selector(close)]; [editors makeObjectsPerformSelector: @selector(close)];
[openEditors removeAllObjects]; [openEditors removeAllObjects];
// [editors makeObjectsPerformSelector: @selector(release)];
[editors removeAllObjects]; [editors removeAllObjects];
// Close the editors in the document window... // Close the editors in the document window...
@ -1710,19 +1717,8 @@ static NSImage *fileImage = nil;
enumerator = [nameTable objectEnumerator]; enumerator = [nameTable objectEnumerator];
while ((obj = [enumerator nextObject]) != nil) 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) if ([obj isKindOfClass: [NSWindow class]] == YES)
{ {
// [obj setReleasedWhenClosed: YES];
[obj close]; [obj close];
RELEASE(obj); RELEASE(obj);
} }