NPNInvoke - Passing plugin data back to browser
I am calling back an object in Javascript using NPAPI. Before this call, the functions I am calling result in proper invocation of functions in JavaScript but it fails in NPN_Invoke
calls.
Code Snippet:
sBrowserFuncs->releaseobject(object_temp);
object_temp = NPVARIANT_TO_OBJECT(args[0]);
sBrowserFuncs->retainobject(object_temp);
if (send_msg1(sBrowserFuncs, instance, msg_rcv, NPVARIANT_TO_OBJECT(args[0]), msg, n开发者_如何学Goame_id))
sendmsg1
spawns a new thread and this thread calls msg_rcv
back. Is it okay for spawned thread to call the main thread function, is that reason of error.
...
Her call to NPN_Invoke
is called
NPVariant from;
STRINGZ_TO_NPVARIANT(sdata->from, from);
NPIdentifier methodId = NPN_GetStringIdentifier("new_msg");
int res = NPN_Invoke(sdata->instance, object_temp, methodId, &from, 1, &result);
sdata->instance
matches with instance
object_temp
is last called object stored
It returns 0, while in successful case it returns 1.
In which case NPN_Invoke
generates 0,
As far as i know , any NPN_* call should be issued from the plugin thread. You can check NPN_PluginThreadAsyncCall
. I this way you can execute methods from another thread , on the main/plugin thread and avoid a nasty crash :)
精彩评论