XMPP::ProcessQuit Class Reference

Listens for termination requests. More...

#include <processquit.h>

List of all members.

Signals

void quit ()

Static Public Member Functions

static ProcessQuitinstance ()
static void reset ()
static void cleanup ()


Detailed Description

Listens for termination requests.

ProcessQuit listens for requests to terminate the application process. On Unix platforms, these are the signals SIGINT, SIGHUP, and SIGTERM. On Windows, these are the console control events for Ctrl+C, console window close, and system shutdown. For Windows GUI programs, ProcessQuit has no effect.

For GUI programs, ProcessQuit is not a substitute for QSessionManager. The only safe way to handle termination of a GUI program in the usual way is to use QSessionManager. However, ProcessQuit does give additional benefit to Unix GUI programs that might be terminated unconventionally, so it can't hurt to support both.

When a termination request is received, the application should exit gracefully, and generally without user interaction. Otherwise, it is at risk of being terminated outside of its control. For example, if a Windows console application does not exit after just a few seconds of attempting to close the console window, Windows will display a prompt to the user asking if the process should be ended immediately.

Using ProcessQuit is easy, and it usually amounts to a single line:

myapp.connect(ProcessQuit::instance(), SIGNAL(quit()), SLOT(do_quit()));

Calling instance() returns a pointer to the global ProcessQuit instance, which will be created if necessary. The quit() signal is emitted when a request to terminate is received. The quit() signal is only emitted once, future termination requests are ignored. Call reset() to allow the quit() signal to be emitted again.


Member Function Documentation

static void XMPP::ProcessQuit::cleanup  )  [static]
 

Frees all resources used by ProcessQuit.

This function will free any resources used by ProcessQuit, including the global instance, and the termination handlers will be uninstalled (reverted to default). Future termination requests will cause the application to exit abruptly.

Note:
You normally do not need to call this function directly. When IrisNet cleans up, it will be called.
See also:
instance

static ProcessQuit* XMPP::ProcessQuit::instance  )  [static]
 

Returns the global ProcessQuit instance.

If the global instance does not exist yet, it will be created, and the termination handlers will be installed.

See also:
cleanup

void XMPP::ProcessQuit::quit  )  [signal]
 

Notification of termination request.

This signal is emitted when a termination request is received. It is only emitted once, unless reset() is called.

Upon receiving this signal, the application should proceed to exit gracefully, and generally without user interaction.

See also:
reset

static void XMPP::ProcessQuit::reset  )  [static]
 

Allows the quit() signal to be emitted again.

ProcessQuit only emits the quit() signal once, so that if a user repeatedly presses Ctrl-C or sends SIGTERM, your shutdown slot will not be called multiple times. This is normally the desired behavior, but if you are ignoring the termination request then you may want to allow future notifications. Calling this function will allow the quit() signal to be emitted again, if a new termination request arrives.

See also:
quit


The documentation for this class was generated from the following file:
Generated on Sun Mar 18 17:58:51 2007 for IrisNet by  doxygen 1.4.6