[vlc-commits] macosx: initializing NSApplication may fail

Felix Paul Kühne git at videolan.org
Thu Dec 15 00:46:40 CET 2016


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Dec 15 00:27:37 2016 +0100| [a2c06b3881f6498a9243ff4b00ed50c4e996dad8] | committer: Felix Paul Kühne

macosx: initializing NSApplication may fail

Do it without crashing if it does

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

 modules/gui/macosx/VLCMain.m | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/modules/gui/macosx/VLCMain.m b/modules/gui/macosx/VLCMain.m
index 039b661..9b08312 100644
--- a/modules/gui/macosx/VLCMain.m
+++ b/modules/gui/macosx/VLCMain.m
@@ -92,14 +92,19 @@ int OpenIntf (vlc_object_t *p_this)
         p_interface_thread = p_intf;
         msg_Dbg(p_intf, "Starting macosx interface");
 
-        [VLCApplication sharedApplication];
-        [VLCMain sharedInstance];
-
-        [NSBundle loadNibNamed:@"MainMenu" owner:[[VLCMain sharedInstance] mainMenu]];
-        [[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:nil];
-
-        msg_Dbg(p_intf, "Finished loading macosx interface");
-        return VLC_SUCCESS;
+        @try {
+            [VLCApplication sharedApplication];
+            [VLCMain sharedInstance];
+
+            [NSBundle loadNibNamed:@"MainMenu" owner:[[VLCMain sharedInstance] mainMenu]];
+            [[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:nil];
+
+            msg_Dbg(p_intf, "Finished loading macosx interface");
+            return VLC_SUCCESS;
+        } @catch (NSException *exception) {
+            msg_Err(p_intf, "Loading the macosx interface failed. Do you have a valid window server?");
+            return VLC_EGENERIC;
+        }
     }
 }
 



More information about the vlc-commits mailing list