comparison mac/dw.m @ 692:bd909322f40d

Added "retain"s to the DWTree/DWContainer/DWListBox classes memory allocation so the data doesn't get free'd unexpectedly. Fixes crashes in HandyFTP.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 10 Mar 2011 02:34:14 +0000
parents 578bbfd8c904
children 2f21ee9d7c7b
comparison
equal deleted inserted replaced
691:578bbfd8c904 692:bd909322f40d
819 -(int)lastQueryPoint { return lastQueryPoint; } 819 -(int)lastQueryPoint { return lastQueryPoint; }
820 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; } 820 -(void)setLastQueryPoint:(int)input { lastQueryPoint = input; }
821 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } 821 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; }
822 -(void)setup 822 -(void)setup
823 { 823 {
824 tvcols = [[NSMutableArray alloc] init]; 824 tvcols = [[[NSMutableArray alloc] init] retain];
825 data = [[NSMutableArray alloc] init]; 825 data = [[[NSMutableArray alloc] init] retain];
826 types = [[NSMutableArray alloc] init]; 826 types = [[[NSMutableArray alloc] init] retain];
827 titles = [NSPointerArray pointerArrayWithWeakObjects]; 827 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain];
828 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]]; 828 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]];
829 } 829 }
830 -(void)selectionChanged:(id)sender 830 -(void)selectionChanged:(id)sender
831 { 831 {
832 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); 832 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9);
979 if(parent) 979 if(parent)
980 { 980 {
981 children = [parent pointerAtIndex:3]; 981 children = [parent pointerAtIndex:3];
982 if(!children) 982 if(!children)
983 { 983 {
984 children = [[NSMutableArray alloc] init]; 984 children = [[[NSMutableArray alloc] init] retain];
985 [parent replacePointerAtIndex:3 withPointer:children]; 985 [parent replacePointerAtIndex:3 withPointer:children];
986 } 986 }
987 } 987 }
988 else 988 else
989 { 989 {
990 if(!data) 990 if(!data)
991 { 991 {
992 children = data = [[NSMutableArray alloc] init]; 992 children = data = [[[NSMutableArray alloc] init] retain];
993 } 993 }
994 } 994 }
995 [children addObject:item]; 995 [children addObject:item];
996 } 996 }
997 -(void *)userdata { return userdata; } 997 -(void *)userdata { return userdata; }