I have a console-based QCoreApplication which has timers and does socket communication and also uses locked mutex.
When I close the application manually, it gives error saying some mutex is locked and it is timed out. Is there any way I can do clean up in a console application when user closes it?
Cleanup should be handled by destructors and child-parent relationship.
Make your master object (the one in the main) a child of QApplication so it is destructed with all its childs before QApplication is.
Are you sure you killed all your threads? If it is a thread with an eventloop be sure to call
QThread::quit()to exit the eventloop before you callQThread::wait()You can also use the void
QApplication::qAddPostRoutine ( QtCleanUpFunction ptr )to do some special cleanup.
For debugging those messages you can use
QtMsgHandler qInstallMsgHandler ( QtMsgHandler h )and write your own message handler to capture those warnings. If you can simulate the problem you can set a breakpoint on the message and see on the stack where the message is coming from.In order to clean up with destructor and child-parent relation ship you can catch the console close signal and call
QCoreApplication::exit()to the application instance.