[futurebasic] Re: [FB] Quitting Application - Carbon Events

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2009 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sun, 8 Feb 2009 18:29:30 -0700
Hi Deep,


On Feb 8, 2009, at 5:47 PM, Deep wrote:

>
> How can one tell the application to Quit gracefully? Using something  
> like
> "STOP" results in a dialog box with "Continue" and "Stop" buttons,  
> which is
> not gracefully closing down.

May I ask what you need to accomplish with a "graceful" shutdown?

My own apps quit for one of two reasons:
(1) user initiates via the quit item on the file menu
(2) Some unexpected condition arises

In the case of number 1, the application process handler intercepts  
the menu option and looks for _kHICommandQuit. At this point a  
shutdown FN is dispatched to check windows and data for saving and  
other standard housekeeping. Apparently, this is already working in  
your code.

In the case of number 2, the user is notified of the unexpected  
condition ( via some dialog box - either sheet alert or standard  
depending on conditions ) and given instructions on next steps. The  
shutdown Fn ( as described above ) may or may not be invoked depending  
on circumstances followed by the FB end statement which just generates  
an exit(0) ( same result as exitToShell ).

It is hard to imagine an app that does not notify the user of a  
failure and offer them guidance; Maybe a background application with  
no UI but this app could also proceed using the steps outlined in #2.

A response describing what you have in mind for "graceful" may help to  
provide a better answer.


> gFBQuit = _true

This global is unnecessary if RunApplicationEventLoop() is used.


Brian S