Commit 671d84da 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 f77d38b5
......@@ -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)
{
......
......@@ -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;
......
......@@ -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;
}
/*
......
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