Odd Crash when adding table columns manually
Odd Crash when adding table columns manually
- Subject: Odd Crash when adding table columns manually
- From: Eric Gorr <email@hidden>
- Date: Tue, 11 Jan 2011 12:06:20 -0500
I've got a sample test project at:
http://ericgorr.net/cocoadev/TableColumnTest.zip
which reproduces the strange crash.
I have a NSTableView to which I need to add NSTableColumns manually using the addTableColumn: method. The problem is that for some reason when I release the window and everything is being deallocated, someone has an extra retain on the table column and it sticks around. This causes a crash because the OS tries to redraw the table which really isn't there.
Note: With the code as written, it will only cause a crash sometimes...if you comment back in the call to the EventAvail function in WindowTestAppDelegate.m, it will crash every time...this is how I ended up finding the odd behavior to begin with - I am working with a cocoa/carbon app and EventAvail is still being called.
I can avoid the crash if, in my TableController class, I manually remove the table column from the table first. Is this what I am expected to do if I manually add the column? I would not have thought so, but perhaps I am wrong...?
In TableController.m, I have the function GetNewColumn which creates a new table column. After I alloc and init the column, I can log the retain count of the column and see that it is 1. After I call setWidth: on the table column, I can see that the retain count is 2.
Can anyone shed some light on what might be going on here and why it is crashing?
(if it matters, I am still running on 10.6.5)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden