Further correction for bug#16587.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@22937 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-05-16 05:00:20 +00:00
parent 5c7c120367
commit 95abbaf5b4
6 changed files with 134 additions and 123 deletions

View file

@ -1,8 +1,21 @@
2006-05-16 00:56 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormDocument.m: Improved logic in detachObject: to clear the
selection in the parent editor and reset the selection in the document
to prevent any problems when an object is removed. Also added
code for removeAllInstancesOfClass: from GormObjectEditor.
* GormCore/GormFunctions.m: allSubviews shouldn't return the view
which is initially passed.
* GormCore/GormInternalViewEditor.m: simplified deleteSelection because
of changes to detachObject:
* GormCore/GormObjectEditor.[hm]: Remove removeAllInstancesOfClass:
from the header and class.
2006-05-15 22:58 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormClassEditor.m: Reload all on calls to reloadData
* GormCore/GormDocument.m: in detachObject: make certain that
window is closed and released.
window is closed and released. Corrects bug#16587.
2006-05-15 21:28 Gregory John Casamento <greg_casamento@yahoo.com>

View file

@ -1236,107 +1236,118 @@ static NSImage *fileImage = nil;
*/
- (void) detachObject: (id)anObject
{
NSString *name = RETAIN([self nameForObject: anObject]); // released at end of method...
GormClassManager *cm = [self classManager];
unsigned count;
NSArray *objs = [self retrieveObjectsForParent: anObject recursively: NO];
id obj = nil;
NSEnumerator *en = [objs objectEnumerator];
if([self containsObject: anObject] == NO)
if([self containsObject: anObject])
{
return;
}
NSString *name = RETAIN([self nameForObject: anObject]); // released at end of method...
unsigned count;
NSArray *objs = [self retrieveObjectsForParent: anObject recursively: NO];
id obj = nil;
NSEnumerator *en = [objs objectEnumerator];
id editor = [self editorForObject: anObject create: NO];
id parent = [self parentEditorForEditor: editor];
[[self editorForObject: anObject create: NO] close];
count = [connections count];
while (count-- > 0)
{
id<IBConnectors> con = [connections objectAtIndex: count];
if ([con destination] == anObject || [con source] == anObject)
// close the editor...
[editor close];
if([parent respondsToSelector: @selector(selectObjects:)])
{
[connections removeObjectAtIndex: count];
[parent selectObjects: [NSArray array]];
}
}
// if the font manager is being reset, zero out the instance variable.
if([name isEqual: @"NSFont"])
{
fontManager = nil;
}
if ([anObject isKindOfClass: [NSWindow class]]
|| [anObject isKindOfClass: [NSMenu class]]
|| [topLevelObjects containsObject: anObject])
{
[objectsView removeObject: anObject];
}
// if it's in the top level items array, remove it.
if([topLevelObjects containsObject: anObject])
{
[topLevelObjects removeObject: anObject];
}
// eliminate it from being the windows/services menu, if it's being detached.
if ([anObject isKindOfClass: [NSMenu class]])
{
if([self windowsMenu] == anObject)
count = [connections count];
while (count-- > 0)
{
[self setWindowsMenu: nil];
}
else if([self servicesMenu] == anObject)
{
[self setServicesMenu: nil];
}
}
/*
* Make sure this window isn't in the list of objects to be made visible
* on nib loading.
*/
if([anObject isKindOfClass: [NSWindow class]])
{
[self setObject: anObject isVisibleAtLaunch: NO];
}
// some objects are given a name, some are not. The only ones we need
// to worry about are those that have names.
if(name != nil)
{
// remove from custom class map...
NSDebugLog(@"Delete from custom class map -> %@",name);
[cm removeCustomClassForName: name];
if([anObject isKindOfClass: [NSScrollView class]])
{
NSView *subview = [anObject documentView];
NSString *objName = [self nameForObject: subview];
NSDebugLog(@"Delete from custom class map -> %@",objName);
[cm removeCustomClassForName: objName];
id<IBConnectors> con = [connections objectAtIndex: count];
if ([con destination] == anObject || [con source] == anObject)
{
[connections removeObjectAtIndex: count];
}
}
// remove from name table...
// if the font manager is being reset, zero out the instance variable.
if([name isEqual: @"NSFont"])
{
fontManager = nil;
}
if ([anObject isKindOfClass: [NSWindow class]]
|| [anObject isKindOfClass: [NSMenu class]]
|| [topLevelObjects containsObject: anObject])
{
[objectsView removeObject: anObject];
}
// if it's in the top level items array, remove it.
if([topLevelObjects containsObject: anObject])
{
[topLevelObjects removeObject: anObject];
}
// eliminate it from being the windows/services menu, if it's being detached.
if ([anObject isKindOfClass: [NSMenu class]])
{
if([self windowsMenu] == anObject)
{
[self setWindowsMenu: nil];
}
else if([self servicesMenu] == anObject)
{
[self setServicesMenu: nil];
}
}
/*
* Make sure this window isn't in the list of objects to be made visible
* on nib loading.
*/
if([anObject isKindOfClass: [NSWindow class]])
{
[anObject setReleasedWhenClosed: YES];
[anObject close];
[self setObject: anObject isVisibleAtLaunch: NO];
}
[nameTable removeObjectForKey: name];
// free...
NSMapRemove(objToName, (void*)anObject);
RELEASE(name);
}
// iterate over the list and remove any subordinate objects.
if(en != nil)
{
while((obj = [en nextObject]) != nil)
// some objects are given a name, some are not. The only ones we need
// to worry about are those that have names.
if(name != nil)
{
[self detachObject: obj];
// remove from custom class map...
NSDebugLog(@"Delete from custom class map -> %@",name);
[classManager removeCustomClassForName: name];
if([anObject isKindOfClass: [NSScrollView class]])
{
NSView *subview = [anObject documentView];
NSString *objName = [self nameForObject: subview];
NSDebugLog(@"Delete from custom class map -> %@",objName);
[classManager removeCustomClassForName: objName];
}
else if([anObject isKindOfClass: [NSWindow class]])
{
[anObject setReleasedWhenClosed: YES];
[anObject close];
}
// make certain it's not displayed, if it's being detached.
if([anObject isKindOfClass: [NSView class]])
{
[anObject removeFromSuperview];
}
[nameTable removeObjectForKey: name];
// free...
NSMapRemove(objToName, (void*)anObject);
}
// iterate over the list and remove any subordinate objects.
if(en != nil)
{
while((obj = [en nextObject]) != nil)
{
[self detachObject: obj];
}
}
[self setSelectionFromEditor: nil]; // clear the selection.
RELEASE(name); // retained at beginning of method...
}
}
@ -1961,7 +1972,22 @@ static NSImage *fileImage = nil;
*/
- (void) removeAllInstancesOfClass: (NSString *)className
{
[objectsView removeAllInstancesOfClass: className];
NSMutableArray *removedObjects = [NSMutableArray array];
NSEnumerator *en = [[self objects] objectEnumerator];
id object = nil;
// locate objects for removal
while((object = [en nextObject]) != nil)
{
NSString *clsForObj = [classManager classNameForObject: object];
if([className isEqual: clsForObj])
{
[removedObjects addObject: object];
}
}
// remove the objects
[self detachObjects: removedObjects];
}
/**
@ -3114,19 +3140,18 @@ static NSImage *fileImage = nil;
*/
- (void) _replaceObjectsWithTemplates: (NSArchiver *)archiver
{
GormClassManager *cm = [self classManager];
NSEnumerator *en = [[self nameTable] keyEnumerator];
id key = nil;
// loop through all custom objects and windows
while((key = [en nextObject]) != nil)
{
id customClass = [cm customClassForName: key];
id customClass = [classManager customClassForName: key];
id object = [self objectForName: key];
id template = nil;
if(customClass != nil)
{
NSString *superClass = [cm nonCustomSuperClassOf: customClass];
NSString *superClass = [classManager nonCustomSuperClassOf: customClass];
template = [GSTemplateFactory templateForObject: object
withClassName: customClass
withSuperClassName: superClass];

View file

@ -101,6 +101,7 @@ NSArray *allSubviews(NSView *view)
{
NSMutableArray *views = [NSMutableArray array];
subviewsForView( view, views );
[views removeObject: view];
return views;
}

View file

@ -308,21 +308,15 @@ static NSImage *horizontalImage;
{
int i;
int count = [selection count];
id temp;
for (i = count - 1; i >= 0; i--)
{
temp = [[selection objectAtIndex: i] editedObject];
id ed = [selection objectAtIndex: i];
id temp = [ed editedObject];
[[selection objectAtIndex: i] detachSubviews];
[ed detachSubviews];
[document detachObject: temp];
[[selection objectAtIndex: i] close];
[temp removeFromSuperview];
[selection removeObjectAtIndex: i];
}
[self selectObjects: [NSArray array]];
}
- (void) mouseDown: (NSEvent *) theEvent

View file

@ -37,7 +37,6 @@
- (BOOL) acceptsTypeFromArray: (NSArray*)types;
- (void) makeSelectionVisible: (BOOL)flag;
- (void) resetObject: (id)anObject;
- (void) removeAllInstancesOfClass: (NSString *)className;
@end
#endif

View file

@ -210,27 +210,6 @@ static NSMapTable *docMap = 0;
}
}
- (void) removeAllInstancesOfClass: (NSString *)className
{
GormClassManager *classManager = [(GormDocument *)document classManager];
NSMutableArray *removedObjects = [NSMutableArray array];
NSEnumerator *en = [objects objectEnumerator];
id object = nil;
// locate objects for removal
while((object = [en nextObject]) != nil)
{
NSString *clsForObj = [classManager classNameForObject: object];
if([className isEqual: clsForObj])
{
[removedObjects addObject: object];
}
}
// remove the objects
[document detachObjects: removedObjects];
}
/*
* Dragging source protocol implementation
*/