Commit 1d8b6ccb authored by Damien Fouilleul's avatar Damien Fouilleul

mozilla: don't hold any reference to root object to prevent ownership issues...

 mozilla: don't hold any reference to root object to prevent ownership issues on plugin destroy, just create it and throw it to the wilderness
parent 488e3ede
...@@ -48,7 +48,6 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) : ...@@ -48,7 +48,6 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
libvlc_instance(NULL), libvlc_instance(NULL),
libvlc_log(NULL), libvlc_log(NULL),
p_scriptClass(NULL), p_scriptClass(NULL),
p_scriptObject(NULL),
p_browser(instance), p_browser(instance),
psz_baseURL(NULL) psz_baseURL(NULL)
#if XP_WIN #if XP_WIN
...@@ -285,8 +284,6 @@ VlcPlugin::~VlcPlugin() ...@@ -285,8 +284,6 @@ VlcPlugin::~VlcPlugin()
{ {
delete psz_baseURL; delete psz_baseURL;
delete psz_target; delete psz_target;
if( p_scriptObject )
NPN_ReleaseObject(p_scriptObject);
if( libvlc_log ) if( libvlc_log )
libvlc_log_close(libvlc_log, NULL); libvlc_log_close(libvlc_log, NULL);
if( libvlc_instance ) if( libvlc_instance )
...@@ -441,15 +438,6 @@ relativeurl: ...@@ -441,15 +438,6 @@ relativeurl:
return NULL; 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 #if XP_UNIX
int VlcPlugin::setSize(unsigned width, unsigned height) int VlcPlugin::setSize(unsigned width, unsigned height)
{ {
......
...@@ -71,7 +71,8 @@ public: ...@@ -71,7 +71,8 @@ public:
void setWindow(const NPWindow *window) void setWindow(const NPWindow *window)
{ npwindow = *window; }; { npwindow = *window; };
NPObject* getScriptObject(); NPClass* getScriptClass()
{ return p_scriptClass; };
void setLog(libvlc_log_t *log) void setLog(libvlc_log_t *log)
{ libvlc_log = log; }; { libvlc_log = log; };
...@@ -100,7 +101,6 @@ private: ...@@ -100,7 +101,6 @@ private:
libvlc_instance_t *libvlc_instance; libvlc_instance_t *libvlc_instance;
libvlc_log_t *libvlc_log; libvlc_log_t *libvlc_log;
NPClass *p_scriptClass; NPClass *p_scriptClass;
NPObject *p_scriptObject;
/* browser reference */ /* browser reference */
NPP p_browser; NPP p_browser;
......
...@@ -99,7 +99,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value ) ...@@ -99,7 +99,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
default: default:
/* move on to instance variables ... */ /* move on to instance variables ... */
break; ;
} }
if( instance == NULL ) if( instance == NULL )
...@@ -119,18 +119,20 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value ) ...@@ -119,18 +119,20 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
switch( variable ) switch( variable )
{ {
case NPPVpluginScriptableNPObject: case NPPVpluginScriptableNPObject:
/* create an instance and return it */ /* retrieve plugin root class */
*(NPObject**)value = p_plugin->getScriptObject(); NPClass *scriptClass = p_plugin->getScriptClass();
if( NULL == *(NPObject**)value ) 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; break;
default: default:
return NPERR_GENERIC_ERROR; ;
} }
return NPERR_NO_ERROR; return NPERR_GENERIC_ERROR;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment