fix for 74938; acrobat fails on plugin registration on Linux; r=av; sr=waterson

This commit is contained in:
serge%netscape.com 2001-09-22 00:18:55 +00:00
Родитель 1c8b45f751
Коммит 826fcb6c8c
2 изменённых файлов: 35 добавлений и 9 удалений

Просмотреть файл

@ -39,6 +39,12 @@
#include <Resources.h> #include <Resources.h>
#endif #endif
//needed for nppdf plugin
#if defined(MOZ_WIDGET_GTK)
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include "gtkxtbin.h"
#endif
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// CID's && IID's // CID's && IID's
@ -235,6 +241,9 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
NS_ADDREF(*aResult); NS_ADDREF(*aResult);
if (!aFileName) //do not call NP_Initialize in this case, bug 74938
return NS_OK;
// we must init here because the plugin may call NPN functions // we must init here because the plugin may call NPN functions
// when we call into the NP_Initialize entry point - NPN functions // when we call into the NP_Initialize entry point - NPN functions
// require that mBrowserManager be set up // require that mBrowserManager be set up
@ -1032,13 +1041,24 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
nsresult res; nsresult res;
if(!npp || !npp->ndata)
return NPERR_INVALID_INSTANCE_ERROR;
switch(variable) { switch(variable) {
#ifdef XP_UNIX #ifdef XP_UNIX
case NPNVxDisplay: case NPNVxDisplay : {
#if defined(MOZ_WIDGET_GTK)
// adobe nppdf calls XtGetApplicationNameAndClass(display, &instance, &class)
// we have to init Xt toolkit before get XtDisplay
// just call gtk_xtbin_new(w,0) once
static GtkWidget *gtkXtBinHolder = 0;
if (!gtkXtBinHolder) {
gtkXtBinHolder = gtk_xtbin_new((GdkWindow*)&gdk_root_parent,0);
// it crashes on destroy, let it leak
// gtk_widget_destroy(gtkXtBinHolder);
}
(*(Display **)result) = GTK_XTBIN(gtkXtBinHolder)->xtdisplay;
return NPERR_NO_ERROR;
#endif
return NPERR_GENERIC_ERROR; return NPERR_GENERIC_ERROR;
}
case NPNVxtAppContext: case NPNVxtAppContext:
return NPERR_GENERIC_ERROR; return NPERR_GENERIC_ERROR;
@ -1046,6 +1066,9 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
#ifdef XP_PC #ifdef XP_PC
case NPNVnetscapeWindow: { case NPNVnetscapeWindow: {
if (!npp || !npp->ndata)
return NPERR_INVALID_INSTANCE_ERROR;
ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata; ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;
nsIPluginInstancePeer *peer; nsIPluginInstancePeer *peer;

Просмотреть файл

@ -393,7 +393,7 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{ {
nsresult rv; nsresult rv;
const char* mimedescr, *name, *description; const char* mimedescr = 0, *name = 0, *description = 0;
char *mdesc,*start,*nexttoc,*mtype,*exten,*descr; char *mdesc,*start,*nexttoc,*mtype,*exten,*descr;
int i,num; int i,num;
@ -422,20 +422,23 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
plugin = do_QueryInterface(factory); plugin = do_QueryInterface(factory);
} else { } else {
// It's old sk00l // It's old sk00l
rv = ns4xPlugin::CreatePlugin(mgr, this->GetCString(), pLibrary, // if fileName parameter == 0 ns4xPlugin::CreatePlugin() will not call NP_Initialize()
rv = ns4xPlugin::CreatePlugin(mgr, 0, pLibrary,
getter_AddRefs(plugin)); getter_AddRefs(plugin));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
} }
if (plugin) { if (plugin) {
info.fFileName = PL_strdup(this->GetCString());
plugin->GetValue(nsPluginVariable_NameString, &name); plugin->GetValue(nsPluginVariable_NameString, &name);
if (!name)
name = PL_strrchr(info.fFileName, '/') + 1;
info.fName = PL_strdup(name); info.fName = PL_strdup(name);
plugin->GetValue(nsPluginVariable_DescriptionString, &description); plugin->GetValue(nsPluginVariable_DescriptionString, &description);
if (!description)
description = "";
info.fDescription = PL_strdup(description); info.fDescription = PL_strdup(description);
info.fFileName = PL_strdup(this->GetCString());
plugin->GetMIMEDescription(&mimedescr); plugin->GetMIMEDescription(&mimedescr);
} else { } else {
info.fName = PL_strdup(this->GetCString()); info.fName = PL_strdup(this->GetCString());