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

Felix Paul Kühne git at videolan.org
Sat Aug 25 13:16:02 CEST 2012


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

macosx/applescript: add missing error handling
(cherry picked from commit 0dd9d856c522526594e0903336fc7b1db362b071)

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

 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 be40d24..3ac23b5 100644
--- a/modules/gui/macosx/applescript.m
+++ b/modules/gui/macosx/applescript.m
@@ -42,31 +42,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