# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1592258755 0 # Node ID 2417bc294e300809198be354d0475cb02d6d807c # Parent 9a5dbda8f2ab4273d6cc5a91d96b40e3f2648ebf Mac: Make sure DWApp is initialized before using it. diff -r 9a5dbda8f2ab -r 2417bc294e30 mac/dw.m --- a/mac/dw.m Sat Jun 13 18:23:04 2020 +0000 +++ b/mac/dw.m Mon Jun 15 22:05:55 2020 +0000 @@ -827,7 +827,7 @@ -(void)runTimer:(id)sender { _event_handler(sender, nil, 0); } @end -NSApplication *DWApp; +NSApplication *DWApp = nil; NSMenu *DWMainMenu; NSFont *DWDefaultFont; DWTimerHandler *DWHandler; @@ -12039,6 +12039,17 @@ [oldfont release]; } +/* If DWApp is uninitialized, initialize it */ +void _dw_app_init(void) +{ + if(!DWApp) + { + DWApp = [NSApplication sharedApplication]; + DWAppDel *del = [[DWAppDel alloc] init]; + [DWApp setDelegate:del]; + } +} + /* * Initializes the Dynamic Windows engine. * Parameters: @@ -12101,9 +12112,7 @@ */ setlocale(LC_ALL, lang && strstr(lang, ".UTF-8") ? lang : "UTF-8"); /* Create the application object */ - DWApp = [NSApplication sharedApplication]; - DWAppDel *del = [[DWAppDel alloc] init]; - [DWApp setDelegate:del]; + _dw_app_init(); /* Create object for handling timers */ DWHandler = [[DWTimerHandler alloc] init]; /* If we aren't using garbage collection we need autorelease pools */ @@ -12631,6 +12640,9 @@ { if(@available(macOS 10.14, *)) { + /* Make sure DWApp is initialized */ + _dw_app_init(); + /* Get the current appearance */ NSAppearance *appearance = [DWApp appearance]; if(appearance) @@ -12685,6 +12697,8 @@ { if(@available(macOS 10.14, *)) { + /* Make sure DWApp is initialized */ + _dw_app_init(); /* Disabled forces the non-dark aqua theme */ if(state == DW_FEATURE_DISABLED) [DWApp setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]];