Menu

#319 Compilation fails on OSX

closed-fixed
nobody
None
5
2019-01-23
2018-10-30
No

When compiling project under OSX, compiler fails with an errors related to the window creation.

The error is related to the type of the delegate being passsed to the NSApp setDelegate method. The fix is quite simple - the NSFileManagerDelegate type needs to be replaced with NSApplicationDelegate.

After this fix, the other problem appears: when the application is ran, its window is not shown on top of other windows, yet the control over the mouse cursor is being taken. The fix is to pass activateIgnoringOtherApps:YES argument to the sharedApplication constructor.

Here is the patch (also put it in the attachments):

Index: source/Irrlicht/CIrrDeviceOSX.mm
===================================================================
--- source/Irrlicht/CIrrDeviceOSX.mm    (revision 5652)
+++ source/Irrlicht/CIrrDeviceOSX.mm    (working copy)
@@ -577,8 +577,8 @@
        if (!CreationParams.WindowId)
        {
            [[NSAutoreleasePool alloc] init];
-           [NSApplication sharedApplication];
-           [NSApp setDelegate:(id<NSFileManagerDelegate>)[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]];
+           [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
+           [NSApp setDelegate:(id<NSApplicationDelegate>)[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]];

             // Create menu
1 Attachments

Discussion

  • Artem Shoobovych

    Oh, by the way, this same fix could be applied to the 1.8 branch to fix the problem there, just the line numbers are different:

    Index: source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
    ===================================================================
    --- source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm  (revision 5652)
    +++ source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm  (working copy)
    @@ -495,8 +495,8 @@
            if(!CreationParams.WindowId) //load menus if standalone application
            {
                [[NSAutoreleasePool alloc] init];
    -           [NSApplication sharedApplication];
    -           [NSApp setDelegate:(id<NSFileManagerDelegate>)[[[AppDelegate alloc] initWithDevice:this] autorelease]];
    +           [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
    +           [NSApp setDelegate:(id<NSApplicationDelegate>)[[[AppDelegate alloc] initWithDevice:this] autorelease]];
                [NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]];
                [NSApp finishLaunching];
            }
    
     

    Last edit: Artem Shoobovych 2018-10-30
  • Michael Zeilfelder

    • status: open --> closed-fixed
     
  • Michael Zeilfelder

    Applied in r5689 (trunk) and r5690 (1.8 branch). Thanks for report and patch!

     

Log in to post a comment.