views:

98

answers:

2

I encountered a problem with updating the status message on Firefox from a Plugin code.

As the documentation says calling NPN_Status works only when called from the main thread. My requirement is to update the status from any thread within the Firefox process.

Any help would be appreciated!

+1  A: 

You can't update it from any thread because that would violate some of the threadsafety rules. You will have to proxy your update back to the main thread.

sdwilsh
could you provide me with any example code / further details on how this proxy thing could be achieved ?
atVelu
You might be able to use https://developer.mozilla.org/en/NPN_PluginThreadAsyncCall, but I'm not certain.
sdwilsh
A: 

Like sdwilsh said, you are to call the NPN_*-functions only from the main thread. NPN_PluginThreadAsyncCall was only introduced in Gecko 1.9 and isn't supported in all current browsers.

Workarounds depend on the platform:

  • on Windows subclass the window your plugin receives, post/send messages to it and invoke the call from the handling window process
  • on Mac with Cocoa you can use e.g. performSelectorOnMainThread
  • on Mac with Carbon you can use invoke the calls on the null event
  • ... etc.
Georg Fritzsche