al_set_window_title() Not Working On OS X El Capitan
Todd Cope

I recently upgraded my Mac to OS X El Capitan and just got around to setting up my development environment on it.

I noticed when running my Allegro applications built in this new environment, the window title is always set to "Allegro" and does not change. Calls to al_set_window_title() don't alter the title.

I am compiling with the latest XCode and using the OS X 10.11 SDK. The example program (ex_window_title) demonstrates the issue nicely.

Peter Hull

I was just looking at this recently. There's quite a lot doesn't work* for El Capitan, particularly the native dialog add on. I think El Capitan is a lot stricter about only accessing the Cocoa functions from the main thread. Maybe this will spur me on to do something about it. :o
Pete
* or at least, throws a warning message onto the console.

[edit]
Are you compiling Allegro yourself? Try changing set_window_title in osxgl.m from:

static void set_window_title(ALLEGRO_DISPLAY *display, const char *title)
{
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   ALLEGRO_DISPLAY_OSX_WIN* dpy = (ALLEGRO_DISPLAY_OSX_WIN*) display;
   [dpy->win setTitle: [NSString stringWithUTF8String:title]];
   [pool drain];
}

to:

static void set_window_title(ALLEGRO_DISPLAY *display, const char *title)
{
   ALLEGRO_DISPLAY_OSX_WIN* dpy = (ALLEGRO_DISPLAY_OSX_WIN*) display;
   NSString* string = [[NSString alloc] initWithUTF8String:title];
   [dpy->win performSelectorOnMainThread:@selector(setTitle:) withObject:string waitUntilDone:YES];
   [string release];
}

Todd Cope

That new code works.

Peter Hull

Hi Todd,
Could you do me a favour and check ex_menu and ex_native_filechooser? These ones didn't work well for me and I wanted to check it wasn't just an oddity of my system. In particular the text log window didn't open reliably.

Thanks,
Pete

Todd Cope

Yeah, the log window is wonky. If I click the button to open the log window in ex_native_filechooser, the log window opens, but I can't close it and I get this output on the terminal:

CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces. 2015-10-28 20:40:32.827 ex_native_filechooser[64820:1026432] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release. Stack:( 0 CoreFoundation 0x00007fff91a4ce32 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff834aedd4 objc_exception_throw + 48 2 CoreFoundation 0x00007fff91ab365d +[NSException raise:format:] + 205 3 Foundation 0x00007fff8df52631 _AssertAutolayoutOnMainThreadOnly + 79 4 Foundation 0x00007fff8df52486 -[NSISEngine withBehaviors:performModifications:] + 31 5 AppKit 0x00007fff9273d072 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 215 6 AppKit 0x00007fff9274fb0c -[NSWindow displayIfNeeded] + 204 7 AppKit 0x00007fff92dce0be ___NSWindowGetDisplayCycleObserver_block_invoke6323 + 476 8 AppKit 0x00007fff9274f4c3 __37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 738 9 QuartzCore 0x00007fff84fb97d1 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 85 10 QuartzCore 0x00007fff84fb8c8c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 160 11 QuartzCore 0x00007fff84fb894c _ZN2CA11Transaction6commitEv + 508 12 QuartzCore 0x00007fff84fce7ee _ZN2CA11Transaction14release_threadEPv + 218 13 libsystem_pthread.dylib 0x00007fff8489b3f1 _pthread_tsd_cleanup + 555 14 libsystem_pthread.dylib 0x00007fff8489af78 _pthread_exit + 117 15 libsystem_pthread.dylib 0x00007fff848999bc pthread_sigmask + 0 16 libsystem_pthread.dylib 0x00007fff8489992e _pthread_body + 0 17 libsystem_pthread.dylib 0x00007fff84897385 thread_start + 13 ) 2015-10-28 20:40:32.831 ex_native_filechooser[64820:1026432] This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release. Stack:( 0 CoreFoundation 0x00007fff91a4ce32 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff834aedd4 objc_exception_throw + 48 2 CoreFoundation 0x00007fff91ab365d +[NSException raise:format:] + 205 3 Foundation 0x00007fff8df52631 _AssertAutolayoutOnMainThreadOnly + 79 4 Foundation 0x00007fff8df59394 -[NSISEngine optimize] + 49 5 AppKit 0x00007fff9273d144 -[NSWindow(NSConstraintBasedLayout) _changeWindowFrameFromConstraintsIfNecessary] + 148 6 Foundation 0x00007fff8df52502 -[NSISEngine withBehaviors:performModifications:] + 155 7 AppKit 0x00007fff9273d072 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 215 8 AppKit 0x00007fff9274fb0c -[NSWindow displayIfNeeded] + 204 9 AppKit 0x00007fff92dce0be ___NSWindowGetDisplayCycleObserver_block_invoke6323 + 476 10 AppKit 0x00007fff9274f4c3 __37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 738 11 QuartzCore 0x00007fff84fb97d1 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 85 12 QuartzCore 0x00007fff84fb8c8c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 160 13 QuartzCore 0x00007fff84fb894c _ZN2CA11Transaction6commitEv + 508 14 QuartzCore 0x00007fff84fce7ee _ZN2CA11Transaction14release_threadEPv + 218 15 libsystem_pthread.dylib 0x00007fff8489b3f1 _pthread_tsd_cleanup + 555 16 libsystem_pthread.dylib 0x00007fff8489af78 _pthread_exit + 117 17 libsystem_pthread.dylib 0x00007fff848999bc pthread_sigmask + 0 18 libsystem_pthread.dylib 0x00007fff8489992e _pthread_body + 0 19 libsystem_pthread.dylib 0x00007fff84897385 thread_start + 13 ) CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces. Mouse clicked at 315,457. CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces. Mouse clicked at 315,457. CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.

Thread #615836. Printed from Allegro.cc