从C++到JS的回调问题

从C++到JS的回调问题,c++,callback,npapi,C++,Callback,Npapi,我是NPAPI的新手。我遇到了一个问题。 在我的插件中,我需要从C++返回一些数据到JavaScript,是的,这是回调。但是回调线程和主线程是独立的线程。所以我使用了NPN_PluginThreadAsyncCall,但这个问题也无法解决。回调时,firefox崩溃了。。。 有人能帮我吗 下面的代码在回调线程中,有人能告诉我它为什么崩溃吗 npnfuncs->pluginthreadasynccall(instance,callBackfunc,(void*)pdata); //////

我是NPAPI的新手。我遇到了一个问题。 在我的插件中,我需要从C++返回一些数据到JavaScript,是的,这是回调。但是回调线程和主线程是独立的线程。所以我使用了NPN_PluginThreadAsyncCall,但这个问题也无法解决。回调时,firefox崩溃了。。。 有人能帮我吗

下面的代码在回调线程中,有人能告诉我它为什么崩溃吗

npnfuncs->pluginthreadasynccall(instance,callBackfunc,(void*)pdata);
/////////////////////////////////////////////////////////////////////
void callBackfunc(void* arg)
{
    NPObject *winobj;
    npnfuncs->getvalue(instance,NPNVWindowNPObject,&winobj);

    NPVariant handler;
    NPIdentifier id1 = npnfuncs->getstringidentifier("MyTest".c_str());
    npnfuncs->getproperty(instance, winobj, id1, &handler);
    NPObject* handlerObj= NPVARIANT_TO_OBJECT(handler);

    NPVariant prototype;
    NPIdentifier id2 = npnfuncs->getstringidentifier("prototype");
    npnfuncs->getproperty(instance, serviceHandlerObj, id2, &prototype);
    NPObject* prototypeObj= NPVARIANT_TO_OBJECT(prototype);

    NPIdentifier id = npnfuncs->getstringidentifier("fun".c_str());

    NPVariant voidResponse;
    int status=npnfuncs->invoke(instance,prototypeObj,id,args,argCount,&voidResponse);
    return;
}    
谢谢 顺致敬意,
大海。。。MyTest.c_str应该是什么?这是C++,不是吗?c_str是std::string类的一个方法,我看不出这里有什么问题,所以尝试在它上执行.c_str甚至不应该编译,除非这里发生了一些我真的不理解的事情

还要注意的是,至少Safari 5.1已经停止支持NPN_PluginThreadAsyncCall,需要使用不同的方法进行跨线程回调。我不知道其他浏览器是否有或将没有;到目前为止,情况似乎并非如此

有没有一个原因,你不只是使用你的插件?它为你解决了所有这些问题,让你只关注你的插件