Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm building a program in QT, I found that the process still in background after I close the window by click the 'X' button.

Just little code in my destructor function.
Posted
Comments
Mohibur Rashid 30-Oct-14 4:24am    
What platform? I mean, Windows, Linux or may be something else...

Because your process is not terminated; the execution did not leave entry point (main) function. Why? Because of some bug in your code. What to do? Fix that bug.

Not enough information? Well, this answer is more informative than your question. :-)

—SA
 
Share this answer
 
Comments
Albert Holguin 30-Oct-14 16:17pm    
+5...very right!
Sergey Alexandrovich Kryukov 30-Oct-14 16:32pm    
Thank you, Albert. :-)
—SA
agent_kruger 31-Oct-14 7:02am    
+5, for your sense of humor
Sergey Alexandrovich Kryukov 31-Oct-14 11:15am    
Thank you very much. Main ingredient of humor is the sense of humor in the readers though. It's a pleasure to learn that we have people with such sense. :-)
By the way, my answer is not just a joke; this is what OP really needs to do. :-)
—SA
agent_kruger 31-Oct-14 16:03pm    
i know sir but it was informative and humorous too
Thank you very much, I have solve this problem.

I have not unregistor a watching thread that I wrote.
 
Share this answer
 
Comments
enhzflep 31-Oct-14 1:48am    
Please do not post replies as solutions. If you wish to reply to someone, you may do it in one of three ways.
1. If you wish to post a reply/comment to a question, click the Have a Question or Comment? button that immediately follows the question.
2. If you wish to post a reply/comment to a solution, see item #1 - swapping the word question for the word solution.
3. If you wish to post a reply/comment to a comment, simply hover your mouse over the comment and click the Reply button.
[Additional answer, after OP's clarification:]

In the "solution" post, OP mentioned that some additional thread does not allow the whole process to terminate. This is the very usual reason.

Just one advice: terminating all the threads before closing main window is the best idea. This way, you can have a full control of the time of termination of abortion of the thread causing the problem. However, in some simple cases when the order of such action is not essential, you can simplify it by making a thread in question a background thread (the name "background" is really misleading). The major difference it makes is: background thread does not prevent the whole process from termination; eventually. such threads will be terminated automatically. Use this property: http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground%28v=vs.110%29.aspx[^].

Again, be careful: you cannot make any assumption when the background thread is automatically terminated, which can create some problems if you somehow rely on that: need to finalize some action, wait for thread termination on some other thread, and so on.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900