On May 5, 2016, at 10:16 AM, Steve Mills <sjmi...@mac.com> wrote:
> 
> On May 05, 2016, at 10:07 AM, Ken Thomases <k...@codeweavers.com> wrote:
> 
>> Don't do that. You must always shunt such work to the main thread.
> 
> Hmm. Has that always been the case with OS X and/or Cocoa?

Yes.

> I know an app should not do any drawing from anything but the main thread, 
> but I thought that all the cocoa controls were smart enough to not draw 
> directly when their set* methods are called. E.g., calling setStringValue 
> will set the internal string and do nothing more than call 
> setNeedsDisplay:YES, deferring drawing to the next time the main thread gets 
> some time. Did I forget or never learn something more critical than that?

Well, you're not supposed to call -setNeedsDisplay: from a background thread, 
either.

From 
<https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/10000057i-CH12-123427>:

"If a secondary thread of an application wants to cause portions of the view to 
be redrawn on the main thread, it must not do so using methods like display, 
setNeedsDisplay:, setNeedsDisplayInRect:, or setViewsNeedDisplay:. Instead, it 
should send a message to the main thread or call those methods using the 
performSelectorOnMainThread:withObject:waitUntilDone: method instead."

Regards,
Ken


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to