NPN_PluginThreadAyncCall

View: New views
2 Messages — Rating Filter:   Alert me  

NPN_PluginThreadAyncCall

by Hanspeter Portner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I can't get this function (NPN_PluginThreadAyncCall) to work. This
function was introduced into xulrunner-1.9. I'm using version 1.9.0.1 of
the SDK.

My System is:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618
Iceweasel/3.0.1 (Debian-3.0.1-1)

I'm using the nullplugin as a template for my custom plugin. I added the
following lines to npunix.c, because this has not yet been added to the
plugin samples in the most recent SDK, but I think it is needed.

****** npunix.c *****
void
NPN_PluginThreadAsyncCall (NPP instance, void (*func)(void *), void
*userData)
{
   CallNPN_PluginThreadAsyncCallProc (
       gNetscapeFuncs.pluginthreadasynccall,
       instance,
       func,
       userData);
}
***** npunix.c *****

In the plugin code I have a function 'myfunc' that I'd like to call from
a function 'mythread' that runs in a different thread.

***** plugin.c *****
void
myfunc (void *data)
{
   printf ("yeah, it works!!\n");
}

void *
mythread (void *data)
{
   NPP instance = (NPP) data;
   NPN_PluginThreadAsyncCall (instance, myfunc, NULL);
   return NULL;
}
***** plugin.c *****

Only thing I get is a SEGFAULT. While debugging, I see, that the funtion
'myfunc' gets never called. SEGFAULT happens upon calling
NPN_PluginThreadAsyncCall. This is a simple example with no threading
issues.

-> Is this a bug?
-> Is this function not yet implemented?
-> Are there additional conditions the plugin has to fulfill apart those
stated by the documentation?
-> Has anyone gotten this function to work?
-> Is there some working sample code that makes use of this function?

Any help is appreciated

Hanspeter
_______________________________________________
dev-tech-plugins mailing list
dev-tech-plugins@...
https://lists.mozilla.org/listinfo/dev-tech-plugins

Re: NPN_PluginThreadAyncCall

by Hanspeter Portner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hanspeter Portner wrote:

> I can't get this function (NPN_PluginThreadAyncCall) to work. This
> function was introduced into xulrunner-1.9. I'm using version 1.9.0.1 of
> the SDK.
>
> My System is:
> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618
> Iceweasel/3.0.1 (Debian-3.0.1-1)
>
> I'm using the nullplugin as a template for my custom plugin. I added the
> following lines to npunix.c, because this has not yet been added to the
> plugin samples in the most recent SDK, but I think it is needed.
>
> ****** npunix.c *****
> void
> NPN_PluginThreadAsyncCall (NPP instance, void (*func)(void *), void
> *userData)
> {
>    CallNPN_PluginThreadAsyncCallProc (
>        gNetscapeFuncs.pluginthreadasynccall,
>        instance,
>        func,
>        userData);
> }
> ***** npunix.c *****
>
> In the plugin code I have a function 'myfunc' that I'd like to call from
> a function 'mythread' that runs in a different thread.
>
> ***** plugin.c *****
> void
> myfunc (void *data)
> {
>    printf ("yeah, it works!!\n");
> }
>
> void *
> mythread (void *data)
> {
>    NPP instance = (NPP) data;
>    NPN_PluginThreadAsyncCall (instance, myfunc, NULL);
>    return NULL;
> }
> ***** plugin.c *****
>
> Only thing I get is a SEGFAULT. While debugging, I see, that the funtion
> 'myfunc' gets never called. SEGFAULT happens upon calling
> NPN_PluginThreadAsyncCall. This is a simple example with no threading
> issues.
>
> -> Is this a bug?
> -> Is this function not yet implemented?
> -> Are there additional conditions the plugin has to fulfill apart those
> stated by the documentation?
> -> Has anyone gotten this function to work?
> -> Is there some working sample code that makes use of this function?
>
> Any help is appreciated
>
> Hanspeter
> _______________________________________________
> dev-tech-plugins mailing list
> dev-tech-plugins@...
> https://lists.mozilla.org/listinfo/dev-tech-plugins
>  
I found the missing link myself.

one has to add an additional line in function NP_Initialize in file
npunix.c. If not, the function does not get registered properly.

**** npunix.c ****

NPError
NP_Initialize (NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs){
...
    gNetscapeFuncs.pluginthreadasynccall = nsTable->pluginthreadasynccall
...
}

**** npunix.c ****

now it works ;-)
_______________________________________________
dev-tech-plugins mailing list
dev-tech-plugins@...
https://lists.mozilla.org/listinfo/dev-tech-plugins
LightInTheBox - Buy quality products at wholesale price!