Re: Progress Sheet on a NSDocument
Re: Progress Sheet on a NSDocument
- Subject: Re: Progress Sheet on a NSDocument
- From: Uli Kusterer <email@hidden>
- Date: Sun, 25 Mar 2007 17:17:32 +0200
Am 25.03.2007 um 16:11 schrieb Alan Smith:
I'm not sure of how the rule that you talk of applies here because
this is a sheet and… well… I don't know much about that rule.
I am displaying the panel from within the thread and I thought that
that might be the cause of this evasive bug so I tried taking it out
but it didn't help.
GUI in Cocoa is not thread safe. Period.
There are no locks, no critical regions, no nothing. The only thing
you should do with user interface is create, use and destroy it on
the main thread. If you manipulate GUI from a non-main thread, AppKit
may meanwhile modify objects in the main thread and concurrent access
by these two threads will blow AppKit's data structures to smithereens.
Similarly, since AppKit doesn't use any locks, it's no use to just
add your own locks, because AppKit may do things behind the scenes
(like throb a default button) that don't go through your locks.
This has nothing to do with whether it's a sheet, a button or
whatever. GUI is currently only safe for main-thread calls. In fact,
anything in Cocoa that isn't explicitly documented as thread-safe isn't.
In recent system releases, Apple snuck in a few tiny thread-safety
additions, but as far as I'm aware it hasn't yet gone far enough to
be useful.
Use performSelectorOnMainThread: and the likes to manipulate GUI
from another thread.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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