Re: Problem with stopModalWithCode on a different thread
Re: Problem with stopModalWithCode on a different thread
- Subject: Re: Problem with stopModalWithCode on a different thread
- From: Corbin Dunn <email@hidden>
- Date: Tue, 22 Jun 2010 14:08:09 -0700
On Jun 21, 2010, at 11:09 AM, Bill Appleton wrote:
> Hi All,
>
> In 64 bit Safari our NPAPI plugin needs to use a few system dialogs for
> opening files, printing, etc.
>
> These system dialogs call stopModalWithCode to deliver the result of the
> dialog interaction back to the runModalForWindow function
>
> But the stopModalWithCode function does not work on another thread, as the
> NSApplication documentation makes clear:
>
> *For example, use abortModal when running in a different thread from the
> Application Kit’s main thread*
>
> When running on a different thread like this runModalForWindow will always
> return zero no matter what is passed to stopModalWithCode
>
> We were easily able to fix this problem in our other dialogs by just saving
> the button clicked in a global and calling abortModal
>
> Can anyone think of a way to fix this for the system dialogs? It seems like
> a trivial problem but I can't think of the best way to fix it
>
> 1) Can anyone explain in more detail what is going on and why?
>
> 2) Could we sub class stopModalWithCode and fix it there?
>
> 3) Can anyone explain how calls to NSApp still work when a child process has
> been created?
>
> 4) Maybe I should subclass NSOpenPanel etc. and try to fix it there?
I'm not familiar with plugin creation in Safari, but I can tell you that the NSSavePanel and NSOpenPanel should not be run on a background thread. You will eventually get crashes; they are not threadsafe.
corbin
_______________________________________________
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