]> git.sesse.net Git - vlc/commitdiff
- mozilla: refcounting is still important, don't mess it up during normal operation
authorDamien Fouilleul <damienf@videolan.org>
Wed, 21 Mar 2007 13:57:12 +0000 (13:57 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Wed, 21 Mar 2007 13:57:12 +0000 (13:57 +0000)
mozilla/control/npolibvlc.cpp

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