Re: threads and sig10/11
Re: threads and sig10/11
- Subject: Re: threads and sig10/11
- From: Chris Hanson <email@hidden>
- Date: Thu, 22 May 2003 09:21:32 -0400
First of all, you're using the AppKit from within a thread. Here are
the rules for using an AppKit from a thread:
(1) The AppKit isn't thread-safe.
(2) The AppKit isn't thread-safe.
(3) The AppKit isn't thread-safe.
Sorry to repeat myself, but it's important to remember. You're sending
yourself -setNeedsDisplay: within your thread. You're also apparently
using QuickDraw within your thread. I'm not sure whether NSImage is
thread-safe, but if it's not *explicitly* documented to be then you
should assume it isn't.
Also, you wrote:
while ( movieFrameNumber < movieFrameCount & movierun ) //[self
movieup])
"&" is bitwise-and in C. "&&" is logical-and. It could be that your
loop isn't doing what you think it is because of this. Or is this what
you intend?
A couple coding-style comments: Use parentheses to make operator
precedence clear. Readers of your code shouldn't have to remember
operator-precedence rules. Underscores are also frowned upon in method
and variable names in Objective-C, in favor of Smalltalk-style
mixed-case names.
Finally, you're creating an autorelease pool with +new and then sending
it -release. The rule for memory management in Cocoa is that you only
-release an object if you received it as the result of an +alloc/-init
pair or -copy. +new is not one of these; [Foo new] is effectively
[[[Foo alloc] init] autorelease].
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Application Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.