• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSApplication terminate: behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSApplication terminate: behavior


  • Subject: NSApplication terminate: behavior
  • From: Andreas Färber <email@hidden>
  • Date: Fri, 20 Jan 2006 02:26:40 +0100

Hello,

I have noticed that NSApplication's run method does not return and call exit() instead. Posts on this list and other places suggest to do cleanup in applicationWillTerminate: or an atexit()-registered callback function. However this does not do what I want it to...
The native Objective-C run method is being called from a managed context and the ObjC runtime / AppKit framework exiting the app does not let Garbage Collection happen for the managed context. If from a managed context I just call the CLR exit() equivalent System.Environment.Exit(0), it does a GC run but does not return to my Main method either, and the menu item stays selected and my window visible for some seconds after the application is Exit'ed.


Calling stop: from applicationShouldTerminate: returning ...Cancel returns from run to Main but just as Exit() the Cocoa termination cleanup is not performed correctly.

And when I throw an Exception in the atexit handler it does not go back through the callstack, probably because all native instances are already dealloc'ed...

So is there some geeky way to write a run equivalent that does not exit but instead return? What does terminate: do exactly anyway apart from calling the delegates? Any docs on that part?

Best regards,

Andreas

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSApplication terminate: behavior
      • From: Camillo Lugaresi <email@hidden>
    • Re: NSApplication terminate: behavior
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: NSLayoutManager subclassing
  • Next by Date: Issues with auto-resizing table view
  • Previous by thread: A caution for those moving to gcc 4.0.1
  • Next by thread: Re: NSApplication terminate: behavior
  • Index(es):
    • Date
    • Thread