• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with stopModalWithCode on a different thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with stopModalWithCode on a different thread


  • Subject: Re: Problem with stopModalWithCode on a different thread
  • From: Bill Appleton <email@hidden>
  • Date: Tue, 22 Jun 2010 11:54:30 -0700

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 <email@hidden>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 (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

  • Follow-Ups:
    • Re: Problem with stopModalWithCode on a different thread
      • From: Charles Srstka <email@hidden>
References: 
 >Problem with stopModalWithCode on a different thread (From: Bill Appleton <email@hidden>)
 >Re: Problem with stopModalWithCode on a different thread (From: Jens Alfke <email@hidden>)
 >Re: Problem with stopModalWithCode on a different thread (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Splitter moves on its own
  • Next by Date: Re: Problem with stopModalWithCode on a different thread
  • Previous by thread: Re: Problem with stopModalWithCode on a different thread
  • Next by thread: Re: Problem with stopModalWithCode on a different thread
  • Index(es):
    • Date
    • Thread