[vlc-commits] macosx/applescript: add missing error handling

Felix Paul Kühne git at videolan.org
Fri Aug 24 20:03:43 CEST 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Aug 24 19:48:31 2012 +0200| [0dd9d856c522526594e0903336fc7b1db362b071] | committer: Felix Paul Kühne

macosx/applescript: add missing error handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0dd9d856c522526594e0903336fc7b1db362b071
---

 modules/gui/macosx/applescript.m |   20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/modules/gui/macosx/applescript.m b/modules/gui/macosx/applescript.m
index d178346..e76426f 100644
--- a/modules/gui/macosx/applescript.m
+++ b/modules/gui/macosx/applescript.m
@@ -43,31 +43,29 @@
     {
         intf_thread_t * p_intf = VLCIntf;
         playlist_t * p_playlist = pl_Get( p_intf );
-        if( p_playlist == NULL )
-        {
-            return nil;
-        }
 
         if ( o_urlString )
         {
             NSURL * o_url;
             input_item_t *p_input;
+            int returnValue;
 
             p_input = input_item_New( [o_urlString fileSystemRepresentation],
                                     [[[NSFileManager defaultManager]
                                     displayNameAtPath: o_urlString] UTF8String] );
-            /* FIXME: playlist_AddInput() can fail */
-            playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
-                               PLAYLIST_END, true, pl_Unlocked );
+            if (!p_input)
+                return nil;
 
+            returnValue = playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
+                               PLAYLIST_END, true, pl_Unlocked );
             vlc_gc_decref( p_input );
 
+            if (returnValue != VLC_SUCCESS)
+                return nil;
+
             o_url = [NSURL fileURLWithPath: o_urlString];
             if( o_url != nil )
-            {
-                [[NSDocumentController sharedDocumentController]
-                    noteNewRecentDocumentURL: o_url];
-            }
+                [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: o_url];
         }
     }
     return nil;



More information about the vlc-commits mailing list