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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com