Fix memory leaks, -copyWithZone:, and use predefined attribute name variables.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19773 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2004-07-24 20:51:39 +00:00
parent 002efa32ed
commit 5d0e3f4755
2 changed files with 17 additions and 5 deletions

View file

@ -1,3 +1,11 @@
2004-07-24 22:47 Alexander Malmberg <alexander@malmberg.org>
* Source/NSToolbarItem.m: Use the predefined variables instead of
inline string literals for attribute names.
([GSToolbarButton -layout], [GSToolbarBackView -drawRect:],
[GSToolbarBackView -layout]): Release attrStr/attrString.
(-copyWithZone:): Return new, not self.
2004-07-23 01:54 Matt Rice <ratmice@yahoo.com>
* Documentation/GuiUser/DefaultsSummary.gsdoc: Document

View file

@ -181,7 +181,7 @@ static NSFont *SmallFont = nil;
// Adjust the layout in accordance with the label
attr = [NSDictionary dictionaryWithObject: font forKey: @"NSFontAttributeName"];
attr = [NSDictionary dictionaryWithObject: font forKey: NSFontAttributeName];
if (label == nil || [label isEqualToString: @""])
label = @"Dummy";
attrStr = [[NSAttributedString alloc] initWithString: label attributes: attr];
@ -212,6 +212,7 @@ static NSFont *SmallFont = nil;
default:
; // Invalid
}
DESTROY(attrStr);
// Set the frame size to use the new layout
@ -324,13 +325,14 @@ static NSFont *SmallFont = nil;
{
// We draw the label
attr = [NSDictionary dictionaryWithObjectsAndKeys: _font,
@"NSFontAttributeName",
NSFontAttributeName,
color,
@"NSForegroundColorAttributeName",
NSForegroundColorAttributeName,
nil];
attrString = [[NSAttributedString alloc] initWithString: [_toolbarItem label] attributes: attr];
textX = (([self frame].size.width - _InsetItemTextX) - [attrString size].width) / 2;
[attrString drawAtPoint: NSMakePoint(textX, _InsetItemTextY)];
DESTROY(attrString);
}
}
@ -392,7 +394,7 @@ static NSFont *SmallFont = nil;
// Adjust the layout in accordance with the label
attr = [NSDictionary dictionaryWithObject: _font forKey: @"NSFontAttributeName"];
attr = [NSDictionary dictionaryWithObject: _font forKey: NSFontAttributeName];
if (label == nil || [label isEqualToString: @""])
label = @"Dummy";
attrStr = [[NSAttributedString alloc] initWithString: label attributes: attr];
@ -460,6 +462,7 @@ static NSFont *SmallFont = nil;
[view setFrameOrigin:
NSMakePoint((layoutedWidth - [view frame].size.width) / 2, insetItemViewY)];
}
DESTROY(attrStr);
}
- (NSToolbarItem *)toolbarItem
@ -1157,7 +1160,8 @@ static NSFont *SmallFont = nil;
[new setMinSize: NSMakeSize(_minSize.width, _minSize.height)];
[new setMaxSize: NSMakeSize(_maxSize.width, _maxSize.height)];
return self;
return new;
}
@end