]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/control/npolibvlc.cpp
Merge branch 1.0-bugfix
[vlc] / projects / mozilla / control / npolibvlc.cpp
index f428187e21857ca5d1801a9cfe1e95f0236b9181..850fcbe79a9c157e8333318b53a814ada599beff 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2002-2009 the VideoLAN team
  *
  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
- *          Jan Paul Dinger <jpd@m2x.nl>
+ *          JP Dinger <jpd@m2x.nl>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -130,17 +130,7 @@ LibvlcRootNPObject::getProperty(int index, NPVariant &result)
                 OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
                 return INVOKERESULT_NO_ERROR;
             case ID_root_VersionInfo:
-            {
-                const char *s = libvlc_get_version();
-                int len = strlen(s);
-                NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
-                if( !retval )
-                    return INVOKERESULT_OUT_OF_MEMORY;
-
-                memcpy(retval, s, len);
-                STRINGN_TO_NPVARIANT(retval, len, result);
-                return INVOKERESULT_NO_ERROR;
-            }
+                return invokeResultString(libvlc_get_version(),result);
             default:
                 ;
         }
@@ -171,18 +161,9 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
         switch( index )
         {
             case ID_root_versionInfo:
-                if( argCount == 0 )
-                {
-                    const char *s = libvlc_get_version();
-                    int len = strlen(s);
-                    NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
-                    if( !retval )
-                        return INVOKERESULT_OUT_OF_MEMORY;
-                    memcpy(retval, s, len);
-                    STRINGN_TO_NPVARIANT(retval, len, result);
-                    return INVOKERESULT_NO_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
+                if( 0 != argCount )
+                    return INVOKERESULT_NO_SUCH_METHOD;
+                return invokeResultString(libvlc_get_version(),result);
             default:
                 ;
         }
@@ -640,10 +621,9 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
 
 LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
 {
-    if( isValid() )
-    {
-        if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj);
-    }
+    // Why the isValid()?
+    if( isValid() && playlistItemsObj )
+        NPN_ReleaseObject(playlistItemsObj);
 };
 
 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
@@ -821,8 +801,8 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
                     }
                 }
 
-                int item = p_plugin->playlist_add_extended_untrusted(url, name, i_options,
-                               const_cast<const char **>(ppsz_options), &ex);
+                int item = p_plugin->playlist_add_extended_untrusted(url, name,
+                      i_options, const_cast<const char **>(ppsz_options), &ex);
                 free(url);
                 free(name);
                 for( int i=0; i< i_options; ++i )