Re: [Gtk-osx-users] Crash on "Quit" in menu.
Status: Beta
Brought to you by:
jralls
From: John R. <jr...@ce...> - 2011-04-11 19:03:47
|
On Apr 11, 2011, at 9:32 AM, Mikkel Kruse Johnsen wrote: > Hi John > > The crash is after NSApplicationWillTerminate, the only way I can get it to not make a crash report, is to Quit Gtk main loop in NSApplicationBlockTermination and return true. Then NSApplicationWillTerminate is never called, but the program exit. > > I don't see the accelerators bypass the Gtk menu, if I keep my normal Gtk menu item with accelerator as cmd-q and hide it, it calls my normal quit function. If I don't have the menuitem, nothing happens when cmd-q is pressed. The same with the other accelerators in main menu and windows menu, they don't work. Sorry, I meant to say that unless you've called gtk_application_set_use_quartz_accelerators(theApp, FALSE), the gtk menu accelerators are bypassed and the app gets a menu notification direct from Quartz rather than getting a key_down notification for Gtk to turn into a menu event. The catch is that Command-Q is special: There is no gtk menu linked to it like there was in ige-mac-integration. Instead, it uses the stock Apple menu item, which sends the NSApplicationShouldTerminate/NSApplicationWillTerminate NSNotification pair, which are acted on by the handlers in GNSApplicationDelegate and GtkApplicationNotify. You should have a handler for NSApplicationWillTerminate and call gtk_main_quit() from there, not from NSApplicationBlockTermination. NSApplicationBlockTermination is so that you can offer the user the opportunity not to quit if she has unsaved work. You haven't yet provided a crash report (from a debug build, please), but I suspect that you're freeing resources in your NSApplicationBlockTermination handler. Don't do that: Do it in the NSApplicationWillTerminate handler. Regards, John Ralls |