mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Fix memory leak when creating matrix cells using inspector. Do not deactivate / close the editor when matrix is expanded.
This commit is contained in:
parent
97f1a8e74d
commit
0284554411
3 changed files with 53 additions and 13 deletions
|
@ -1238,9 +1238,9 @@ static NSImage *fileImage = nil;
|
|||
}
|
||||
|
||||
/**
|
||||
* Deteach anObject from the document.
|
||||
* Detach anObject from the document. Optionally close the editor
|
||||
*/
|
||||
- (void) detachObject: (id)anObject
|
||||
- (void) detachObject: (id)anObject closeEditor: (BOOL)close_editor
|
||||
{
|
||||
if([self containsObject: anObject])
|
||||
{
|
||||
|
@ -1251,7 +1251,11 @@ static NSImage *fileImage = nil;
|
|||
id parent = [self parentEditorForEditor: editor];
|
||||
|
||||
// close the editor...
|
||||
[editor close];
|
||||
if (close_editor)
|
||||
{
|
||||
[editor close];
|
||||
}
|
||||
|
||||
if([parent respondsToSelector: @selector(selectObjects:)])
|
||||
{
|
||||
[parent selectObjects: [NSArray array]];
|
||||
|
@ -1346,28 +1350,48 @@ static NSImage *fileImage = nil;
|
|||
}
|
||||
|
||||
// iterate over the list and remove any subordinate objects.
|
||||
[self detachObjects: objs];
|
||||
[self detachObjects: objs closeEditors: close_editor];
|
||||
|
||||
[self setSelectionFromEditor: nil]; // clear the selection.
|
||||
if (close_editor)
|
||||
{
|
||||
[self setSelectionFromEditor: nil]; // clear the selection.
|
||||
}
|
||||
|
||||
RELEASE(name); // retained at beginning of method...
|
||||
[self touch]; // set the document as modified
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach every object in anArray from the document.
|
||||
* Detach object from document.
|
||||
*/
|
||||
- (void) detachObject: (id)object
|
||||
{
|
||||
[self detachObject: object closeEditor: YES];
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach every object in anArray from the document. Optionally closing editors.
|
||||
*/
|
||||
- (void) detachObjects: (NSArray*)anArray
|
||||
- (void) detachObjects: (NSArray*)anArray closeEditors: (BOOL)close_editors
|
||||
{
|
||||
NSEnumerator *enumerator = [anArray objectEnumerator];
|
||||
NSObject *obj;
|
||||
|
||||
while ((obj = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[self detachObject: obj];
|
||||
[self detachObject: obj closeEditor: close_editors];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach all objects in array from the document.
|
||||
*/
|
||||
- (void) detachObjects: (NSArray *)array
|
||||
{
|
||||
[self detachObjects: array closeEditors: YES];
|
||||
}
|
||||
|
||||
/**
|
||||
* The path to where the .gorm file is saved.
|
||||
*/
|
||||
|
|
|
@ -114,11 +114,21 @@ IB_EXTERN NSString *IBWillCloseDocumentNotification;
|
|||
*/
|
||||
- (void) detachObject: (id)anObject;
|
||||
|
||||
/**
|
||||
* Detaches an object from the receiver, closes editor if asked. GNUstep extension.
|
||||
*/
|
||||
- (void) detachObject: (id)anObject closeEditor: (BOOL)close_editor;
|
||||
|
||||
/**
|
||||
* Detaches an array of objects from the receiver.
|
||||
*/
|
||||
- (void) detachObjects: (NSArray*)anArray;
|
||||
|
||||
/**
|
||||
* Detaches an array of objects from the receiver. Closes editor if asked. GNUstep extension.
|
||||
*/
|
||||
- (void) detachObjects: (id)anObject closeEditors: (BOOL)close_editor;
|
||||
|
||||
/**
|
||||
* The path of the file which represents the document.
|
||||
*/
|
||||
|
|
|
@ -101,10 +101,16 @@ NSUInteger colsStepperValue;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) _refreshCells
|
||||
{
|
||||
id<IBDocuments> document = [(id<IB>)NSApp activeDocument];
|
||||
[document detachObjects: [object cells] closeEditors: NO];
|
||||
[document attachObjects: [object cells] toParent: object];
|
||||
}
|
||||
|
||||
/* Commit changes that the user makes in the Attributes Inspector */
|
||||
- (void) ok: (id) sender
|
||||
{
|
||||
id<IBDocuments> document = [(id<IB>)NSApp activeDocument];
|
||||
if (sender == autosizeSwitch)
|
||||
{
|
||||
[object setAutosizesCells: ([sender state] == NSOnState)];
|
||||
|
@ -221,6 +227,7 @@ NSUInteger colsStepperValue;
|
|||
}
|
||||
}
|
||||
[self _displayObject: object resize: YES];
|
||||
[self _refreshCells];
|
||||
}
|
||||
else if(sender == rowsStepper)
|
||||
{
|
||||
|
@ -243,6 +250,7 @@ NSUInteger colsStepperValue;
|
|||
[sender setIntValue: num];
|
||||
rowsStepperValue = num;
|
||||
[self _displayObject: object resize: YES];
|
||||
[self _refreshCells];
|
||||
}
|
||||
else if(sender == colsStepper)
|
||||
{
|
||||
|
@ -265,6 +273,7 @@ NSUInteger colsStepperValue;
|
|||
[sender setIntValue: num];
|
||||
colsStepperValue = num;
|
||||
[self _displayObject: object resize: YES];
|
||||
[self _refreshCells];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -280,10 +289,7 @@ NSUInteger colsStepperValue;
|
|||
[prototypeMatrix putCell: [object prototype] atRow:0 column:0];
|
||||
}
|
||||
|
||||
// [document detachObjects: [object cells]];
|
||||
[document attachObjects: [object cells] toParent: object];
|
||||
|
||||
[super ok:sender];
|
||||
[super ok:sender];
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue