I have a console-based QCoreApplication
which has timers and does socket communication and also uses locked mutex.
When I close the application manually
Turns out that closing command line application (checked on Win7 & VS2010) by pressing 'close' (red x button on title bar) passes the STATUS_CONTROL_C_EXIT
signal to the application. All threads are aborted with this code.
The thread 'Main Thread' (0x980) has exited with code -1073741510 (0xc000013a).
The thread 'QThread' (0x2388) has exited with code -1073741510 (0xc000013a).
That means that there is no way to intercept this with the QCoreApplication::aboutToQuit()
signal.
Take a look at winnt.h
or ntstatus.h
. That is the value assigned to the
manifest constant STATUS_CONTROL_C_EXIT
. The runtime is just
choosing to end your program with the code to note the user's cancel
operation.