Skip to content

Commit ef048ed

Browse files
authored
Merge pull request #1179 from s4y/fix-1164
Don't rely on NSCache to retain newly-created lines.
2 parents 3453167 + 21a6fba commit ef048ed

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/MacVim/MMCoreTextView.m

+2-3
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ - (CTLineRef)lineForCharacterString:(NSString *)string
11381138
if (!strCache){
11391139
strCache = characterLines[key] = [[[NSCache alloc] init] autorelease];
11401140
}
1141-
CTLineRef line = (CTLineRef)[strCache objectForKey:string];
1141+
CTLineRef line = (CTLineRef)[[strCache objectForKey:string] retain];
11421142
if (!line) {
11431143
NSAttributedString *attrString = [[NSAttributedString alloc]
11441144
initWithString:string
@@ -1150,9 +1150,8 @@ - (CTLineRef)lineForCharacterString:(NSString *)string
11501150
line = CTLineCreateWithAttributedString((CFAttributedStringRef)attrString);
11511151
[attrString release];
11521152
[strCache setObject:(id)line forKey:[[string copy] autorelease]];
1153-
CFRelease(line);
11541153
}
1155-
return line;
1154+
return (CTLineRef)[(id)line autorelease];
11561155
}
11571156

11581157
@end // MMCoreTextView (Private)

0 commit comments

Comments
 (0)