]> git.lizzy.rs Git - irrlicht.git/commitdiff
Gracefully handle lack of bundle on macOS
authorsfan5 <sfan5@live.de>
Mon, 31 Jan 2022 19:48:00 +0000 (20:48 +0100)
committersfan5 <sfan5@live.de>
Mon, 31 Jan 2022 20:03:21 +0000 (21:03 +0100)
should fix https://github.com/minetest/minetest/issues/10170

source/Irrlicht/CIrrDeviceOSX.mm

index dea86d9440b7939260e475f91f54e50ec5cba51e..066539ca9d32d98d15e564c5e0721cb7848738fe 100644 (file)
@@ -553,7 +553,6 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
        IsActive(true), IsFullscreen(false), IsShiftDown(false), IsControlDown(false), IsResizable(false)
 {
        struct utsname name;
-       NSString *path;
 
 #ifdef _DEBUG
        setDebugName("CIrrDeviceMacOSX");
@@ -568,27 +567,31 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
                        [[NSAutoreleasePool alloc] init];
                        [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
                        [NSApp setDelegate:(id<NSApplicationDelegate>)[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]];
-            
+
             // Create menu
-            
+
             NSString* bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
-            
+            if (bundleName == nil)
+                bundleName = @"Irrlicht";
+
             NSMenu* mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease];
             NSMenu* menu = [[[NSMenu alloc] initWithTitle:bundleName] autorelease];
             NSMenuItem* menuItem = [mainMenu addItemWithTitle:bundleName action:nil keyEquivalent:@""];
             [mainMenu setSubmenu:menu forItem:menuItem];
             menuItem = [menu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
             [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
-            
+
             [NSApp setMainMenu:mainMenu];
 
             [NSApp finishLaunching];
                }
 
-               path = [[NSBundle mainBundle] bundlePath];
-        path = [path stringByAppendingString:@"/Contents/Resources"];
-               chdir([path fileSystemRepresentation]);
-        [path release];
+               NSString *path = [[NSBundle mainBundle] bundlePath];
+               if (path != nil) {
+                       path = [path stringByAppendingString:@"/Contents/Resources"];
+                       chdir([path fileSystemRepresentation]);
+                       [path release];
+               }
        }
 
        uname(&name);