Minor retain/release fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6637 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-06-03 04:47:10 +00:00
parent 620dfcfa5b
commit ef98c0cf61
2 changed files with 46 additions and 29 deletions

View file

@ -1,3 +1,8 @@
2000-06-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAttributedString.m: ([-setAlignment:range:]) retain/release
problem fixed.
Thu Jun 1 21:50:34 2000 Nicola Pero <nicola@brainstorm.co.uk> Thu Jun 1 21:50:34 2000 Nicola Pero <nicola@brainstorm.co.uk>
* Source/NSScrollView.m ([NSScrollView -tile]): Fixed position of * Source/NSScrollView.m ([NSScrollView -tile]): Fixed position of

View file

@ -177,7 +177,7 @@ paraBreakCSet()
atIndex: range.location atIndex: range.location
effectiveRange: &range]; effectiveRange: &range];
if (style) if (style != nil)
{ {
return [NSDictionary dictionaryWithObject: style return [NSDictionary dictionaryWithObject: style
forKey: NSParagraphStyleAttributeName]; forKey: NSParagraphStyleAttributeName];
@ -294,12 +294,12 @@ paraBreakCSet()
range = NSMakeRange(0, location); range = NSMakeRange(0, location);
if (!inWord) if (!inWord)
{ {
range = [str rangeOfCharacterFromSet: wordCSet() range = [str rangeOfCharacterFromSet: wordCSet()
options: NSBackwardsSearch|NSLiteralSearch options: NSBackwardsSearch|NSLiteralSearch
range: range]; range: range];
if (range.length == 0) if (range.length == 0)
return 0; return 0;
range = NSMakeRange(0, range.location); range = NSMakeRange(0, range.location);
} }
range = [str rangeOfCharacterFromSet: wordBreakCSet() range = [str rangeOfCharacterFromSet: wordBreakCSet()
options: NSBackwardsSearch|NSLiteralSearch options: NSBackwardsSearch|NSLiteralSearch
@ -548,9 +548,8 @@ documentAttributes: (NSDictionary**)dict
- (void) setAlignment: (NSTextAlignment)alignment - (void) setAlignment: (NSTextAlignment)alignment
range: (NSRange)range range: (NSRange)range
{ {
id value; id value;
unsigned loc = range.location; unsigned loc = range.location;
NSRange effRange;
if (range.location < 0 || NSMaxRange(range) > [self length]) if (range.location < 0 || NSMaxRange(range) > [self length])
{ {
@ -560,20 +559,34 @@ documentAttributes: (NSDictionary**)dict
while (loc < NSMaxRange(range)) while (loc < NSMaxRange(range))
{ {
BOOL copiedStyle = NO;
NSRange effRange;
NSRange newRange;
value = [self attribute: NSParagraphStyleAttributeName value = [self attribute: NSParagraphStyleAttributeName
atIndex: loc atIndex: loc
effectiveRange: &effRange]; effectiveRange: &effRange];
newRange = NSIntersectionRange(effRange, range);
if (value == nil) if (value == nil)
value = [NSMutableParagraphStyle defaultParagraphStyle]; {
value = [NSMutableParagraphStyle defaultParagraphStyle];
}
else else
value = [value mutableCopy]; {
value = [value mutableCopy];
copiedStyle = YES;
}
[value setAlignment: alignment]; [value setAlignment: alignment];
[self addAttribute: NSParagraphStyleAttributeName [self addAttribute: NSParagraphStyleAttributeName
value: value value: value
range: NSIntersectionRange(effRange, range)]; range: newRange];
if (copiedStyle == YES)
{
RELEASE(value);
}
loc = NSMaxRange(effRange); loc = NSMaxRange(effRange);
} }
} }
@ -592,7 +605,6 @@ documentAttributes: (NSDictionary**)dict
[NSException raise: NSRangeException [NSException raise: NSRangeException
format: @"RangeError in method -fixFontAttributeInRange:"]; format: @"RangeError in method -fixFontAttributeInRange:"];
} }
} }
- (void) fixParagraphStyleAttributeInRange: (NSRange)range - (void) fixParagraphStyleAttributeInRange: (NSRange)range
@ -1007,24 +1019,24 @@ documentAttributes: (NSDictionary**)dict
float firstLineIndent; float firstLineIndent;
float lineIndent; float lineIndent;
NSParagraphStyle *paraStyle = [attributes objectForKey: NSParagraphStyle *paraStyle = [attributes objectForKey:
NSParagraphStyleAttributeName]; NSParagraphStyleAttributeName];
NSTextAlignment alignment = [paraStyle alignment]; NSTextAlignment alignment = [paraStyle alignment];
switch (alignment) switch (alignment)
{ {
case NSRightTextAlignment: case NSRightTextAlignment:
[headerString appendString: @"\\qr"]; [headerString appendString: @"\\qr"];
break; break;
case NSCenterTextAlignment: case NSCenterTextAlignment:
[headerString appendString: @"\\qc"]; [headerString appendString: @"\\qc"];
break; break;
case NSLeftTextAlignment: case NSLeftTextAlignment:
[headerString appendString: @"\\ql"]; [headerString appendString: @"\\ql"];
break; break;
case NSJustifiedTextAlignment: case NSJustifiedTextAlignment:
[headerString appendString: @"\\qj"]; [headerString appendString: @"\\qj"];
break; break;
default: break; default: break;
} }
// write first line indent and left indent // write first line indent and left indent