# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1307891190 0 # Node ID 25e0317335fcdd8197446b1cd05a12c72adf7d63 # Parent b673b25bbd777cc1abdd9a043d0ff66bed9a9c79 Switched from using NSPointerArray to NSMutableArray on Mac to avoid the duplicate string crashes that have been plaguing the tree control. diff -r b673b25bbd77 -r 25e0317335fc mac/dw.m --- a/mac/dw.m Sat Jun 11 17:54:41 2011 +0000 +++ b/mac/dw.m Sun Jun 12 15:06:30 2011 +0000 @@ -339,9 +339,13 @@ if([object isKindOfClass:[NSOutlineView class]]) { id item = event; - NSString *nstr = [item pointerAtIndex:1]; + NSString *nstr = [item objectAtIndex:1]; text = (char *)[nstr UTF8String]; - user = [item pointerAtIndex:2]; + NSValue *value = [item objectAtIndex:2]; + if(value && [value isKindOfClass:[NSValue class]]) + { + user = [value pointerValue]; + } } dw_pointer_query_pos(&x, &y); @@ -368,7 +372,7 @@ if([object isKindOfClass:[NSOutlineView class]]) { item = (id)event; - NSString *nstr = [item pointerAtIndex:1]; + NSString *nstr = [item objectAtIndex:1]; if(nstr) { @@ -378,7 +382,12 @@ { text = NULL; } - user = [item pointerAtIndex:2]; + + NSValue *value = [item objectAtIndex:2]; + if(value && [value isKindOfClass:[NSValue class]]) + { + user = [value pointerValue]; + } int result = treeselectfunc(handler->window, item, text, handler->data, user); if(text) { @@ -1606,17 +1615,22 @@ @end /* Dive into the tree showing all nodes */ -void _free_tree_recurse(NSMutableArray *node, NSPointerArray *item) -{ - if(node) +void _free_tree_recurse(NSMutableArray *node, NSMutableArray *item) +{ + if(node && ([node isMemberOfClass:[NSMutableArray class]])) { int count = (int)[node count]; int z; for(z=0;z