[Swfdec-commits] src/plugin.c

Benjamin Otte company at kemper.freedesktop.org
Fri May 2 10:14:06 PDT 2008


 src/plugin.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 5fa756abd9562432be81a07bfceaed615d46d603
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri May 2 19:11:45 2008 +0200

    move toolkit check to instantiation code
    
    Apparently Webkit gets scared when calling NPN_GetValue with a NULL instance
    pointer and returns an error. So we let poor Webkit create an instance first
    and only query interesting things then.

diff --git a/src/plugin.c b/src/plugin.c
index a935dfd..5dee945 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -209,10 +209,16 @@ plugin_new (NPMIMEType mime_type, NPP instance,
   SwfdecPlayer *player;
   int i;
   gboolean windowless = FALSE, opaque = FALSE;
+  NPNToolkitType toolkit = 0;
 
   if (instance == NULL)
     return NPERR_INVALID_INSTANCE_ERROR;
 
+  /* we must be GTK 2 */
+  if (CallNPN_GetValueProc(mozilla_funcs.getvalue, instance,
+	NPNVToolkit, (void *) &toolkit) || toolkit != NPNVGtk2)
+    return NPERR_INCOMPATIBLE_VERSION_ERROR;
+
   if (!swfdec_mozilla_make_sure_this_thing_stays_in_memory ()) {
     g_printerr ("Ensuring the plugin stays in memory did not work.\n"
 	        "This happens when the plugin was copied from its installed location at " PLUGIN_FILE ".\n"
@@ -424,8 +430,6 @@ plugin_url_notify (NPP instance, const char* url, NPReason reason, void* notifyD
 NPError
 NP_Initialize (NPNetscapeFuncs * moz_funcs, NPPluginFuncs * plugin_funcs)
 {
-  NPNToolkitType toolkit = 0;
-
   if (moz_funcs == NULL || plugin_funcs == NULL)
     return NPERR_INVALID_FUNCTABLE_ERROR;
 
@@ -438,11 +442,6 @@ NP_Initialize (NPNetscapeFuncs * moz_funcs, NPPluginFuncs * plugin_funcs)
 
   mozilla_funcs = *moz_funcs;
 
-  /* we must be GTK 2 */
-  if (CallNPN_GetValueProc(mozilla_funcs.getvalue, NULL,
-	NPNVToolkit, (void *) &toolkit) || toolkit != NPNVGtk2)
-    return NPERR_INCOMPATIBLE_VERSION_ERROR;
-
   memset (plugin_funcs, 0, sizeof (NPPluginFuncs));
   plugin_funcs->size = sizeof (NPPluginFuncs);
   plugin_funcs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;


More information about the Swfdec-commits mailing list