]> git.sesse.net Git - vlc/commitdiff
mozilla: don't hold any reference to root object to prevent ownership issues on...
authorDamien Fouilleul <damienf@videolan.org>
Thu, 22 Mar 2007 16:56:59 +0000 (16:56 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Thu, 22 Mar 2007 16:56:59 +0000 (16:56 +0000)
mozilla/vlcplugin.cpp
mozilla/vlcplugin.h
mozilla/vlcshell.cpp

index 71af56480913a4cbfdeda879c8222f5f927d53fc..a9e1781d2ddb928c12036ed85605133ca4559058 100644 (file)
@@ -48,7 +48,6 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
     libvlc_instance(NULL),
     libvlc_log(NULL),
     p_scriptClass(NULL),
-    p_scriptObject(NULL),
     p_browser(instance),
     psz_baseURL(NULL)
 #if XP_WIN
@@ -285,8 +284,6 @@ VlcPlugin::~VlcPlugin()
 {
     delete psz_baseURL;
     delete psz_target;
-    if( p_scriptObject )
-        NPN_ReleaseObject(p_scriptObject);
     if( libvlc_log )
         libvlc_log_close(libvlc_log, NULL);
     if( libvlc_instance )
@@ -441,15 +438,6 @@ relativeurl:
     return NULL;
 }
 
-NPObject* VlcPlugin::getScriptObject()
-{
-    if( NULL == p_scriptObject )
-    {
-        p_scriptObject = NPN_CreateObject(p_browser, p_scriptClass);
-    }
-    return NPN_RetainObject(p_scriptObject);
-}
-
 #if XP_UNIX
 int  VlcPlugin::setSize(unsigned width, unsigned height)
 {
index 66c578fff4c615a0811a78f93ce9b46f13f46874..4ff0af525471274c89dac19f8debfdbe15fed04c 100644 (file)
@@ -71,7 +71,8 @@ public:
     void                setWindow(const NPWindow *window)
                             { npwindow = *window; };
 
-    NPObject*           getScriptObject();
+    NPClass*            getScriptClass()
+                            { return p_scriptClass; };
 
     void                setLog(libvlc_log_t *log)
                             { libvlc_log = log; };
@@ -100,7 +101,6 @@ private:
     libvlc_instance_t   *libvlc_instance;
     libvlc_log_t        *libvlc_log;
     NPClass             *p_scriptClass;
-    NPObject            *p_scriptObject;
 
     /* browser reference */
     NPP     p_browser;
index 02c8a5f3e2b820411077e8e3b5ad3154f102c4b5..28df94e82b841dffadc0fbbcd2b213f71c82971f 100644 (file)
@@ -99,7 +99,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
 
         default:
             /* move on to instance variables ... */
-            break;
+            ;
     }
 
     if( instance == NULL )
@@ -119,18 +119,20 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
     switch( variable )
     {
         case NPPVpluginScriptableNPObject:
-            /* create an instance and return it */
-            *(NPObject**)value = p_plugin->getScriptObject();
-            if( NULL == *(NPObject**)value )
+            /* retrieve plugin root class */
+            NPClass *scriptClass = p_plugin->getScriptClass();
+            if( scriptClass )
             {
-                return NPERR_OUT_OF_MEMORY_ERROR;
+                /* create an instance and return it */
+                *(NPObject**)value = NPN_CreateObject(instance, scriptClass);
+                return NPERR_NO_ERROR;
             }
             break;
 
         default:
-            return NPERR_GENERIC_ERROR;
+            ;
     }
-    return NPERR_NO_ERROR;
+    return NPERR_GENERIC_ERROR;
 }
 
 /*