[vlc-commits] macosx: initializing NSApplication may fail

Felix Paul Kühne git at videolan.org
Wed Feb 8 19:05:14 CET 2017


vlc/vlc-2.2 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Dec 15 22:16:38 2016 +0100| [7e1aa028d737446b36ded5ce45af1a6e2d3a3806] | committer: Felix Paul Kühne

macosx: initializing NSApplication may fail

Do it without crashing if it does

Manual backport of a2c06b38

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=7e1aa028d737446b36ded5ce45af1a6e2d3a3806
---

 modules/gui/macosx/intf.m | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index d7e1b63..b4e0571 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -113,15 +113,21 @@ static VLCDocumentController *documentController = nil;
 int OpenIntf (vlc_object_t *p_this)
 {
     NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
-    [VLCApplication sharedApplication];
-    // Register subclass for recent items controller
-    documentController = [[VLCDocumentController alloc] init];
+    @try {
+        [VLCApplication sharedApplication];
+        // Register subclass for recent items controller
+        documentController = [[VLCDocumentController alloc] init];
+
+        intf_thread_t *p_intf = (intf_thread_t*) p_this;
+        msg_Dbg(p_intf, "Starting macosx interface");
+        Run(p_intf);
 
-    intf_thread_t *p_intf = (intf_thread_t*) p_this;
-    msg_Dbg(p_intf, "Starting macosx interface");
-    Run(p_intf);
+        [documentController release];
+    } @catch (NSException *exception) {
+        [o_pool release];
+        return VLC_EGENERIC;
+    }
 
-    [documentController release];
     [o_pool release];
     return VLC_SUCCESS;
 }



More information about the vlc-commits mailing list