Add same object/key to NSMapTable

2009-06-17 Thread Nathan Vander Wilt
The following (simplified test case) code will crash with NSZombieEnabled: NSMapTable* testTable = [NSMapTable mapTableWithStrongToStrongObjects]; NSString* o = [@test_object mutableCopy]; NSString* k = @test_key; [testTable setObject:o forKey:k]; [o release]; [testTable setObject:o forKey:k];

Re: Add same object/key to NSMapTable

2009-06-17 Thread Kyle Sluder
On Wed, Jun 17, 2009 at 6:33 PM, Nathan Vander Wiltnate-li...@calftrail.com wrote: I could find no documentation to the effect that re-assigning an object is not allowed, so can I assume this is indeed unintentional? If so, I've got this test case in project form and would be happy to file a

Re: Add same object/key to NSMapTable

2009-06-17 Thread Nathan Vander Wilt
On Jun 17, 2009, at 6:44 PM, Kyle Sluder wrote: On Wed, Jun 17, 2009 at 6:33 PM, Nathan Vander Wiltnate-li...@calftrail.com wrote: I could find no documentation to the effect that re-assigning an object is not allowed, so can I assume this is indeed unintentional? If so, I've got this

Re: Add same object/key to NSMapTable

2009-06-17 Thread Bill Bumgarner
On Jun 17, 2009, at 8:48 PM, Nathan Vander Wilt wrote: In the meantime, the explicit case you present is always going to be fraught with peril, because after you release o, you have relinquished all rights to it. It's now a weak reference. Isn't it acceptable practice to let a container

Re: Add same object/key to NSMapTable

2009-06-17 Thread Kyle Sluder
On Wed, Jun 17, 2009 at 6:48 PM, Nathan Vander Wiltnate-li...@calftrail.com wrote: Isn't it acceptable practice to let a container object I hold to maintain its objects on my behalf? Not explicitly, no. Take -[NSWindowController delegate], for example. Because delegates are a weak reference,

Re: Add same object/key to NSMapTable

2009-06-17 Thread Jim Correia
On Wed, Jun 17, 2009 at 9:51 PM, Bill Bumgarner b...@mac.com wrote: You can't assume that the container didn't make a copy or do something else. If you need the object, you should hold a retain. In general, I agree. However, the following code is also problematic: [o release]; [testTable

Re: Add same object/key to NSMapTable

2009-06-17 Thread Michael Ash
On Wed, Jun 17, 2009 at 9:51 PM, Bill Bumgarnerb...@mac.com wrote: On Jun 17, 2009, at 8:48 PM, Nathan Vander Wilt wrote: In the meantime, the explicit case you present is always going to be fraught with peril, because after you release o, you have relinquished all rights to it.  It's now a

Re: Add same object/key to NSMapTable

2009-06-17 Thread Michael Ash
On Wed, Jun 17, 2009 at 10:10 PM, Jim Correiajim.corr...@pobox.com wrote: On Wed, Jun 17, 2009 at 9:51 PM, Bill Bumgarner b...@mac.com wrote: You can't assume that the container didn't make a copy or do something else. If you need the object, you should hold a retain. In general, I agree.