Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
My program wont close!
darkp03 last edited by
Im having a serious issue, and I dont know how to solve this.
This has been happening for a long time now, but it never caused me any trouble, but yesterday a whole server was shut down because of this issue, and i need to solve it ASAP.
My problem is, with certain programs, that when the user closes it (by clicking on the "x" on the main window) the program will close, (at least the window) but keep working on the windows task manager, and the only way to close it is opening the task manager and stopping it from there.
Yesterday, a collegue closed my application, and opened it again, and he never realized that he had 2 apps running, causing major trouble.
Ive tried many things, for example, on the destructor, calling delete to every object that might be holding my program (timers for example) and using commands on the destructor that closes the program, but theres no case, the graphical part closes, but the program still runs on the background.
About my program:
I dont know what part of the program is holding it, and preventing it from closing, but im going to briefly describe what it does.
My program has a QFileSystemWatcher that is checking all the time for new files on a specific folder.
If a file arrives, it does minor procesing and it sends a tcp message to another application of mine, after a few seconds my second program answers to this message, with either "succesfull" or "unsuccesfull" so my program moves this file, and continues to watch the folder
It also has a connection with an SQL database, which reads and edits periodically.
Thats basically all, it has q tcpsocket, a QFileSystemWatcher, and some timers that make him regulary check an SQL database and run some simple queries, something of all that wont close, and I dont know why.
Please let me know if theres any infomation you need to help me solve my issue.
What I basically need, is to be 100% certain that if someone closes my program, the program and all of its process actually close.
Thanks in advance
Sounds like you should also ensure that you only have one instance running at any time. QtSingleApplication might be of help for that.
As for your problem, what size are the files you are moving ? How are you moving it ?
You'll have to ensure that you set every condition to true and wait for them to end. Depending on what DoStuff does, you should split is smaller pieces to allow the loop break more easily. Typically moving big files should be done in chunks.
If you have than may loop in your application, you should also consider moving some of these functionalities in their own thread.