Commit 614d104e authored by Damien Fouilleul's avatar Damien Fouilleul

- mozilla: refcounting is still important, don't mess it up during normal operation

parent f0996b77
...@@ -48,11 +48,11 @@ LibvlcRootNPObject::~LibvlcRootNPObject() ...@@ -48,11 +48,11 @@ LibvlcRootNPObject::~LibvlcRootNPObject()
*/ */
if( isValid() ) if( isValid() )
{ {
if( audioObj ) NPN_ReleaseObject(audioObj); if( audioObj ) NPN_ReleaseObject(audioObj);
if( inputObj ) NPN_ReleaseObject(inputObj); if( inputObj ) NPN_ReleaseObject(inputObj);
if( logObj ) NPN_ReleaseObject(logObj); if( logObj ) NPN_ReleaseObject(logObj);
if( playlistObj ) NPN_ReleaseObject(playlistObj); if( playlistObj ) NPN_ReleaseObject(playlistObj);
if( videoObj ) NPN_ReleaseObject(videoObj); if( videoObj ) NPN_ReleaseObject(videoObj);
} }
} }
...@@ -86,44 +86,34 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVaria ...@@ -86,44 +86,34 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVaria
switch( index ) switch( index )
{ {
case ID_root_audio: case ID_root_audio:
// create child object in lazyman fashion to avoid ownership problem with firefox // create child object in lazyman fashion to avoid ownership problem with firefox
if( audioObj ) if( ! audioObj )
NPN_RetainObject(audioObj); audioObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcAudioNPObject>::getClass());
else OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
audioObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcAudioNPObject>::getClass());
OBJECT_TO_NPVARIANT(audioObj, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_input: case ID_root_input:
// create child object in lazyman fashion to avoid ownership problem with firefox // create child object in lazyman fashion to avoid ownership problem with firefox
if( inputObj ) if( ! inputObj )
NPN_RetainObject(inputObj); inputObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcInputNPObject>::getClass());
else OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
inputObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcInputNPObject>::getClass());
OBJECT_TO_NPVARIANT(inputObj, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_log: case ID_root_log:
// create child object in lazyman fashion to avoid ownership problem with firefox // create child object in lazyman fashion to avoid ownership problem with firefox
if( logObj ) if( ! logObj )
NPN_RetainObject(logObj); logObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcLogNPObject>::getClass());
else OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
logObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcLogNPObject>::getClass());
OBJECT_TO_NPVARIANT(logObj, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_playlist: case ID_root_playlist:
// create child object in lazyman fashion to avoid ownership problem with firefox // create child object in lazyman fashion to avoid ownership problem with firefox
if( playlistObj ) if( ! playlistObj )
NPN_RetainObject(playlistObj); playlistObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcPlaylistNPObject>::getClass());
else OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
playlistObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcPlaylistNPObject>::getClass());
OBJECT_TO_NPVARIANT(playlistObj, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_video: case ID_root_video:
// create child object in lazyman fashion to avoid ownership problem with firefox // create child object in lazyman fashion to avoid ownership problem with firefox
if( videoObj ) if( ! videoObj )
NPN_RetainObject(videoObj); videoObj = NPN_CreateObject(_instance,RuntimeNPClass<LibvlcVideoNPObject>::getClass());
else OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
videoObj = NPN_CreateObject(_instance,RuntimeNPClass<LibvlcVideoNPObject>::getClass());
OBJECT_TO_NPVARIANT(videoObj, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_VersionInfo: case ID_root_VersionInfo:
{ {
...@@ -1057,7 +1047,7 @@ LibvlcLogNPObject::~LibvlcLogNPObject() ...@@ -1057,7 +1047,7 @@ LibvlcLogNPObject::~LibvlcLogNPObject()
{ {
if( isValid() ) if( isValid() )
{ {
if( messagesObj ) NPN_ReleaseObject(messagesObj); if( messagesObj ) NPN_ReleaseObject(messagesObj);
} }
}; };
...@@ -1088,12 +1078,10 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian ...@@ -1088,12 +1078,10 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian
{ {
case ID_log_messages: case ID_log_messages:
{ {
// create child object in lazyman fashion to avoid ownership problem with firefox // create child object in lazyman fashion to avoid ownership problem with firefox
if( messagesObj ) if( ! messagesObj )
NPN_RetainObject(messagesObj); messagesObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessagesNPObject>::getClass());
else OBJECT_TO_NPVARIANT(NPN_RetainObject(messagesObj), result);
messagesObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessagesNPObject>::getClass());
OBJECT_TO_NPVARIANT(messagesObj, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_log_verbosity: case ID_log_verbosity:
...@@ -1311,7 +1299,7 @@ LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject() ...@@ -1311,7 +1299,7 @@ LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
{ {
if( isValid() ) if( isValid() )
{ {
if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj); if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj);
} }
}; };
...@@ -1368,12 +1356,10 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV ...@@ -1368,12 +1356,10 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
} }
case ID_playlist_items: case ID_playlist_items:
{ {
// create child object in lazyman fashion to avoid ownership problem with firefox // create child object in lazyman fashion to avoid ownership problem with firefox
if( playlistItemsObj ) if( ! playlistItemsObj )
NPN_RetainObject(playlistItemsObj); playlistItemsObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcPlaylistItemsNPObject>::getClass());
else OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
playlistItemsObj = NPN_CreateObject(_instance, RuntimeNPClass<LibvlcPlaylistItemsNPObject>::getClass());
OBJECT_TO_NPVARIANT(playlistItemsObj, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default: default:
......
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