Important: The information in this document is obsolete and should not be used for new development.
Terminating the Application
MacApp includes a general-purpose mechanism for patching Toolbox traps, described in"Trap Patching," beginning on page 82. That mechanism is used to guarantee the application has a chance to perform necessary cleanup, even when it is terminated abnormally.During initialization, MacApp uses its trap-patching mechanism to patch the
ExitToShellToolbox trap so that the call goes to theExitToShellCleanupMacApproutine. That routine gets the trap address forExitToShell, callsCleanupMacApp, then callsExitToShell, terminating the application.The
CleanupMacApproutine first unpatches theExitToShellpatch. It then callsgApplication->Terminate, giving the application a chance to do any special cleanup before it relinquishes control. PatchingExitToShellensures thatgApplication->Terminateis called, even if a user forces the application to quit. TheCleanupMacApproutine finally frees various items and unpatches any other traps the application has patched, a service that is likely to make your application popular with other programs.The
Terminatemethod is implemented inTEventHandler, but does nothing in that implementation. Your application class can overrideTerminateif it needs to do any special cleanup.