mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 13:20:47 +00:00
Minor corrections to toolbar to correct a memory leak.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19684 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d8efe75de4
commit
6e7ef17e28
3 changed files with 59 additions and 15 deletions
34
ChangeLog
34
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2004-07-05 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSToolbar.m: [NSToolbar _setWindow:] added logic
|
||||
to accept the NSWindowWillCloseNotification, since the toolbar
|
||||
will need to remove itself from the "toolbars" master array.
|
||||
Also added a method called [NSToolbar _handleNotification:]
|
||||
to do the actual removal.
|
||||
* Source/GSToolbar.m: [GSToolbar _setDelegate:] toolbar
|
||||
no longer retains it's delegate. This prevents the delegate
|
||||
from leaking.
|
||||
|
||||
2004-07-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSOutlineView.m: Moved private methods into separate
|
||||
|
@ -18,19 +29,22 @@
|
|||
ivar to the GSNibContainer class and the method to retrieve it.
|
||||
* Source/GSNibTemplates.m: Move the private class GSNibItemCollector
|
||||
from NSBundleAdditions.m to GSNibTemplates.m. This helped clean up
|
||||
code and also facilitated the changes necessary for the new .gorm version.
|
||||
Also changed the signature of awakeWithContext: so it only takes the context
|
||||
dictionary as an argument and no longer requires the items to be passed in.
|
||||
code and also facilitated the changes necessary for the new .gorm
|
||||
version. Also changed the signature of awakeWithContext: so it
|
||||
only takes the context dictionary as an argument and no longer
|
||||
requires the items to be passed in.
|
||||
Changed the awakeWithContext method to efficiently retain the objects.
|
||||
In initWithCoder: and encodeWithCoder: added new section for updated
|
||||
version. Added some logic to collect the top level items at that time
|
||||
so that version 0 and version 1 .gorm files load in a precisely equivalent
|
||||
manner. Also, updated a change made by Alex Malmberg which was causing
|
||||
the designated initializers to not be called.
|
||||
* Source/NSBundleAdditions.m: Moved class to GSNibTemplates as described
|
||||
above. Cleaned up implementation of +loadNibNamed:context:.
|
||||
* Source/NSNib.m: Removed some of the code which was there to collect top level
|
||||
items. Also cleaned up some of the code with the new implementation.
|
||||
so that version 0 and version 1 .gorm files load in a precisely
|
||||
equivalent manner. Also, updated a change made by Alex Malmberg
|
||||
which was causing the designated initializers to not be called.
|
||||
* Source/NSBundleAdditions.m: Moved class to GSNibTemplates as
|
||||
described above. Cleaned up implementation of +loadNibFile:
|
||||
externalNameTable:withZone:.
|
||||
* Source/NSNib.m: Removed some of the code which was there to
|
||||
collect top level items. Also cleaned up some of the code with
|
||||
the new implementation.
|
||||
|
||||
2004-06-28 Serg Stoyan <stoyan255@ukr.net>
|
||||
|
||||
|
|
|
@ -1041,6 +1041,8 @@ static id validationCenter;
|
|||
|
||||
- (void) _setDelegate: (id)delegate broadcast: (BOOL)broadcast
|
||||
{
|
||||
if(_delegate)
|
||||
[nc removeObserver: _delegate name: nil object: self];
|
||||
|
||||
if (_delegate == delegate
|
||||
|| (broadcast == NO && [_delegate isMemberOfClass: [delegate class]]))
|
||||
|
@ -1063,10 +1065,8 @@ static id validationCenter;
|
|||
CHECK_REQUIRED_METHOD(toolbarAllowedItemIdentifiers:);
|
||||
CHECK_REQUIRED_METHOD(toolbarDefaultItemIdentifiers:);
|
||||
|
||||
if (_delegate)
|
||||
[nc removeObserver: _delegate name: nil object: self];
|
||||
|
||||
ASSIGN(_delegate, delegate);
|
||||
// assign the delegate...
|
||||
_delegate = delegate;
|
||||
|
||||
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
||||
if ([_delegate respondsToSelector: @selector(toolbar##notif_name:)]) \
|
||||
|
|
|
@ -247,13 +247,43 @@ static const int current_version = 1;
|
|||
}
|
||||
}
|
||||
|
||||
// handle notifications
|
||||
|
||||
- (void) handleNotification: (NSNotification *)notification
|
||||
{
|
||||
NSMutableArray *toolbars = [GSToolbar _toolbars];
|
||||
|
||||
// We currently only worry about when our window closes.
|
||||
// It's necessary to remove the toolbar which belongs to this
|
||||
// window from the master list, so that it doesn't cause a
|
||||
// memory leak.
|
||||
[toolbars removeObjectIdenticalTo: self];
|
||||
}
|
||||
|
||||
// Private Accessors
|
||||
|
||||
- (void)_setWindow: (NSWindow *)window
|
||||
{
|
||||
_window = window;
|
||||
if(_window != window)
|
||||
{
|
||||
if(_window)
|
||||
{
|
||||
[nc removeObserver: _window];
|
||||
}
|
||||
|
||||
if(window)
|
||||
{
|
||||
// watch for this window closing....
|
||||
[nc addObserver: self
|
||||
selector: @selector(handleNotification:)
|
||||
name: NSWindowWillCloseNotification
|
||||
object: window];
|
||||
}
|
||||
}
|
||||
|
||||
// We don't do an ASSIGN because the toolbar view retains us.
|
||||
// call [NSWindow(Toolbar) setToolbar:] to set the toolbar window
|
||||
_window = window;
|
||||
}
|
||||
|
||||
- (NSWindow *) _window
|
||||
|
|
Loading…
Reference in a new issue