#include <processquit.h>
Signals | |
| void | quit () |
Static Public Member Functions | |
| static ProcessQuit * | instance () |
| static void | reset () |
| static void | cleanup () |
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.
|
|
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.
|
|
|
Returns the global ProcessQuit instance. If the global instance does not exist yet, it will be created, and the termination handlers will be installed.
|
|
|
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.
|
|
|
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.
|
1.4.6