"Application quit unexpectedly"

Nibbie
Posts: 3
Joined: 2011.02
Post: #1
I'm currently porting a game to MacOSX, and most of it is working, but when I'm press ESC to quit the game, it quits, and the a dialog pops up, saying "<nameofgame> quit unexpectedly, open again or ignore?"

Now, I want to know if anyone knows what is the cause of this behavior.
When the ESC key is pressed, I release all resources in memory, destroy the application window, and call exit(0), what could be the problem?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You crashed. Run in the debugger, you'll get more info.

You needn't clean anything up when the user quits. Just exit(0) as quickly as possible.
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #3
My guess would be that the crash happens sometime during your attempt to "clean things up" for the quit. As OSC says, don't bother with the other stuff like closing the window or releasing resources, just call exit(0) and be done with it.
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #4
I'd guess that you are probably releasing something too early and the OS is killing your app for a segmentation fault. The application window is a suspect. Anything that is instantiated in your main NIB file, as your main window is likely to be, will be destroyed automatically for you when the app quits. If you destroy it programmatically then Cocoa comes along and tries to destroy it again you'll get a segmentation fault.
I'd suggest you look at the run log (add some printf()s to your destructors if you need to) and look for anything suspicious. Also, if see what the debugger says when the app crashes.

On another note, escape shouldn't quit the app anyway. Command-Q is the keyboard shortcut for quit. In a lot of games escape will bring up a menu, but I can't think of any where it quits the game - even on Windows (although, admittedly, it has been a long time since I played any games on Windows).
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2011.02
Post: #5
Hey, thanks for the quick answers!
A crash, true, is probably that, I will check that now Smile
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2011.02
Post: #6
Well, removing DisposeWindow before terminating solves the problem (I guess MacOSX automatically destroys windows).
(I'm using Carbon instead of Cocoa, because I'm using Pascal instead of objective C)
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
You do realize that Carbon is deprecated, unavailable in 64-bit, and generally completely without any kind of future, right?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  "Quit gamed and choose restart" funkboy 3 6,721 Dec 20, 2012 08:40 PM
Last Post: funkboy
  Enabling the "quit" menu function in an SDL program ferum 2 4,159 Sep 10, 2006 02:35 PM
Last Post: PowerMacX