browser-plugin: Refactor plugin_object_set_property, and fix a bug
If the user did "obj.onchanged = 1;" or passed another sort of invalid type, then we would clear the old listener as well as throw an exception. https://bugzilla.gnome.org/show_bug.cgi?id=668517
This commit is contained in:
parent
15563444cf
commit
26991988cb
@ -809,6 +809,26 @@ plugin_object_get_property (NPObject *npobj,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool
|
||||
plugin_object_set_callback (NPObject **listener,
|
||||
const NPVariant *value)
|
||||
{
|
||||
if (!NPVARIANT_IS_OBJECT (*value) && !NPVARIANT_IS_NULL (*value))
|
||||
return FALSE;
|
||||
|
||||
if (*listener)
|
||||
funcs.releaseobject (*listener);
|
||||
*listener = NULL;
|
||||
|
||||
if (NPVARIANT_IS_OBJECT (*value))
|
||||
{
|
||||
funcs.retainobject (*listener);
|
||||
*listener = NPVARIANT_TO_OBJECT (*value);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool
|
||||
plugin_object_set_property (NPObject *npobj,
|
||||
NPIdentifier name,
|
||||
@ -816,42 +836,11 @@ plugin_object_set_property (NPObject *npobj,
|
||||
{
|
||||
PluginObject *obj;
|
||||
|
||||
if (!plugin_object_has_property (npobj, name))
|
||||
return FALSE;
|
||||
|
||||
if (name == onextension_changed_id)
|
||||
{
|
||||
obj = (PluginObject*) npobj;
|
||||
if (obj->listener)
|
||||
funcs.releaseobject (obj->listener);
|
||||
|
||||
obj->listener = NULL;
|
||||
if (NPVARIANT_IS_OBJECT (*value))
|
||||
{
|
||||
obj->listener = NPVARIANT_TO_OBJECT (*value);
|
||||
funcs.retainobject (obj->listener);
|
||||
return TRUE;
|
||||
}
|
||||
else if (NPVARIANT_IS_NULL (*value))
|
||||
return TRUE;
|
||||
}
|
||||
return plugin_object_set_callback (&obj->listener, value);
|
||||
|
||||
if (name == onrestart_id)
|
||||
{
|
||||
obj = (PluginObject*) npobj;
|
||||
if (obj->restart_listener)
|
||||
funcs.releaseobject (obj->restart_listener);
|
||||
|
||||
obj->restart_listener = NULL;
|
||||
if (NPVARIANT_IS_OBJECT (*value))
|
||||
{
|
||||
obj->restart_listener = NPVARIANT_TO_OBJECT (*value);
|
||||
funcs.retainobject (obj->restart_listener);
|
||||
return TRUE;
|
||||
}
|
||||
else if (NPVARIANT_IS_NULL (*value))
|
||||
return TRUE;
|
||||
}
|
||||
return plugin_object_set_callback (&obj->restart_listener, value);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user