Hi all,

Thanks for the tips.

i have verified that this code actually IS running on the main thread, i was
wrong about that in my original message. Here is the situation. WebKit
launches WebKitPluginHost.app and that is the process that runs my NPAPI
plugin. The plugin is called on the main thread, and NSApp is already
initialized. However I can absolutely confirm this bug is happening, I
logged a webkit bug on it, no telling what will happen with that.

i was able to fix this problem in my dialogs (not system dialogs) by just
saving the clicked button in a global and calling abortModal, then i just
return the global & it works perfectly. So Charles, your tip about "write
your own method that wraps stopModalWithCode" is probably the practical way
to fix this. But I can't subclass NSApp (it is already initialized) & I'm
having trouble figuring out how to write a method that can just intercept a
class message in general. Is that possible?


thanks in advance,

bill appleton






On Mon, Jun 21, 2010 at 7:56 PM, Charles Srstka <cocoa...@charlessoft.com>wrote:

> On Jun 21, 2010, at 7:33 PM, Jens Alfke wrote:
>
> > In general, if you have some kind of background activity that needs to
> call some AppKit method like this, use -performSelectorOnMainThread:.
>
> If you’re requiring 10.6 or greater, you can use one of these methods as
> well:
>
> [[NSOperationQueue mainQueue] addOperationWithBlock:^{
>        // do something on the main thread
> }];
>
> or, alternatively:
>
> dispatch_async(dispatch_get_main_queue(), ^{
>        // do something on the main thread
> });
>
> This can make things much less of a pain when you need to run a method that
> takes something other than an object for a parameter, such as
> stopModalWithCode: (the other options being to write your own method that
> wraps stopModalWithCode: and run that on the main thread, or use
> NSInvocation).
>
> Charles
_______________________________________________

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

Reply via email to