Re: Crash in NSControl's sizeToFit
Re: Crash in NSControl's sizeToFit
- Subject: Re: Crash in NSControl's sizeToFit
- From: Kyle Sluder <email@hidden>
- Date: Mon, 1 Feb 2010 08:46:03 -0800
On Mon, Feb 1, 2010 at 8:16 AM, email@hidden
<email@hidden> wrote:
> Quick followup: is it safe to set the token field's object value from
> the background thread, or do I need to do it on the main thread as
> well? Or to put it in more general terms: are _all_ calls to AppKit
> from a background thread disallowed, or only those regarding updating
> the UI?
Threading Programming Guide > Thread Safety Summary > NSView Restrictions:
"The NSView class is generally thread-safe, with a few exceptions. You
should create, destroy, resize, move, and perform other operations on
NSView objects only from the main thread of an application. Drawing
from secondary threads is thread-safe as long as you bracket drawing
calls with calls to lockFocusIfCanDraw and unlockFocus."
You are not drawing, so what you are doing falls under "other operations."
> Also, is it thread-safe to bracket the sizeToFit method between
> lockFocusIfCanDraw and unlockFocus, rather than performing the
> resizing on the main thread?
-sizeToFit is not a drawing method. It's unclear why you think
-lockFocusIfCanDraw will help here.
--Kyle Sluder
_______________________________________________
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