Mercurial > dwindows
comparison mac/dw.m @ 2816:4521f014bb17
Fix some memory leaks reported by Xcode's Instruments.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 01 Aug 2022 22:46:31 +0000 |
parents | 1efe0ed76629 |
children | 3731f21dd678 |
comparison
equal
deleted
inserted
replaced
2815:1efe0ed76629 | 2816:4521f014bb17 |
---|---|
3106 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; | 3106 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; |
3107 [super keyDown:theEvent]; | 3107 [super keyDown:theEvent]; |
3108 } | 3108 } |
3109 -(void)insertTab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectNextKeyView:self]; } | 3109 -(void)insertTab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectNextKeyView:self]; } |
3110 -(void)insertBacktab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectPreviousKeyView:self]; } | 3110 -(void)insertBacktab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectPreviousKeyView:self]; } |
3111 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [scrollview release]; [super dealloc]; } | 3111 -(void)dealloc { UserData *root = userdata; _dw_remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [self clear]; [scrollview release]; [super dealloc]; } |
3112 @end | 3112 @end |
3113 | 3113 |
3114 /* Dive into the tree freeing all desired child nodes */ | 3114 /* Dive into the tree freeing all desired child nodes */ |
3115 void _dw_free_tree_recurse(NSMutableArray *node, NSMutableArray *item) | 3115 void _dw_free_tree_recurse(NSMutableArray *node, NSMutableArray *item) |
3116 { | 3116 { |
6396 DW_FUNCTION_ADD_PARAM3(handle, buffer, startpoint) | 6396 DW_FUNCTION_ADD_PARAM3(handle, buffer, startpoint) |
6397 DW_FUNCTION_RETURN(dw_mle_import, unsigned int) | 6397 DW_FUNCTION_RETURN(dw_mle_import, unsigned int) |
6398 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, buffer, const char *, startpoint, int) | 6398 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, buffer, const char *, startpoint, int) |
6399 { | 6399 { |
6400 DW_FUNCTION_INIT; | 6400 DW_FUNCTION_INIT; |
6401 DW_LOCAL_POOL_IN; | |
6401 DWMLE *mle = handle; | 6402 DWMLE *mle = handle; |
6402 unsigned int retval; | 6403 unsigned int retval; |
6403 NSTextStorage *ts = [mle textStorage]; | 6404 NSTextStorage *ts = [mle textStorage]; |
6404 NSString *nstr = [NSString stringWithUTF8String:buffer]; | 6405 NSString *nstr = [NSString stringWithUTF8String:buffer]; |
6405 NSColor *fgcolor = [ts foregroundColor]; | 6406 NSColor *fgcolor = [ts foregroundColor]; |
6406 NSFont *font = [ts font]; | 6407 NSFont *font = [ts font]; |
6407 NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; | 6408 NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; |
6408 [attributes setObject:(fgcolor ? fgcolor : [NSColor textColor]) forKey:NSForegroundColorAttributeName]; | 6409 [attributes setObject:(fgcolor ? fgcolor : [NSColor textColor]) forKey:NSForegroundColorAttributeName]; |
6409 if(font) | 6410 if(font) |
6410 [attributes setObject:font forKey:NSFontAttributeName]; | 6411 [attributes setObject:font forKey:NSFontAttributeName]; |
6411 NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes]; | 6412 NSAttributedString *nastr = [[[NSAttributedString alloc] initWithString:nstr attributes:attributes] autorelease]; |
6412 NSUInteger length = [ts length]; | 6413 NSUInteger length = [ts length]; |
6413 if(startpoint < 0) | 6414 if(startpoint < 0) |
6414 startpoint = 0; | 6415 startpoint = 0; |
6415 if(startpoint > length) | 6416 if(startpoint > length) |
6416 startpoint = (int)length; | 6417 startpoint = (int)length; |
6417 [ts insertAttributedString:nastr atIndex:startpoint]; | 6418 [ts insertAttributedString:nastr atIndex:startpoint]; |
6418 retval = (unsigned int)strlen(buffer) + startpoint; | 6419 retval = (unsigned int)strlen(buffer) + startpoint; |
6420 DW_LOCAL_POOL_OUT; | |
6419 DW_FUNCTION_RETURN_THIS(retval); | 6421 DW_FUNCTION_RETURN_THIS(retval); |
6420 } | 6422 } |
6421 | 6423 |
6422 /* | 6424 /* |
6423 * Grabs text from an MLE box. | 6425 * Grabs text from an MLE box. |