Re: odd problems with NSData / OpenGL
Re: odd problems with NSData / OpenGL
- Subject: Re: odd problems with NSData / OpenGL
- From: David Duncan <email@hidden>
- Date: Tue, 8 Dec 2009 08:42:15 -0800
On Dec 7, 2009, at 11:46 PM, Henri Häkkinen wrote:
> I have a simple Cocoa document-based application, which uses a custom NSOpenGLView derived class. This view object has a reference to the document object (this binding is set in the nib file), and the document has a reference to a Mesh class. Mesh loads vertices and indexed triangular faces from a file, and stores them as NSData objects containing vertex arrays, intended to be used with glVertexPointer etc. OpenGL calls.
>
> The mesh is drawn in drawRect: of the view class using OpenGL. First call of this method works fine and the mesh is rendered. However, after calling setNeedsDisplay (for example in reshape method or anywhere) the program crashes with EXC_BAD_ACCESS when the drawRect method is trying to access the NSData objects of the mesh. Using the debugger I can see that the pointers (both the document reference, mesh reference and the NSData pointers inside the mesh) remain the same between the calls of drawRect:, as in nothing seems to get overwritten accidentally or anything.
More than likely this is a memory management problem. Specifically, you probably aren't claiming ownership of the NSData object that you store in your instance variable, and thus it is being deallocated out from under you.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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