Why we should use 'clean'
-
I know it's too late for me to ask but i am facing some problems now. I am using some threads in my test projects. When i terminate UI, i can't restart project until press the clean. Can someone explain clean's function? What it does, why and when we should use, or should we?
-
Where is the clean ? Which class ? Also you should avoid terminate of thread.
-
@R_Irudezu said in Why we should use 'clean':
When i terminate UI, i can't restart project until press the clean.
How do you stop your threads when you close your UI?
Can someone explain clean's function? What it does, why and when we should use, or should we?
Do you mean Qt Creator's "Clean" function? It basically deletes the files produced by your compiler. It is normally used to delete stale files after you make big changes to your project.
-
Mr. @dheerendra I uploaded a screenshot. Why i should avoid terminate the threads?
@JKSH I am stopping thread that i created like that:
MainWindow::~MainWindow() { delete ui; worker1->terminate(); //a thread that subclassed from QThread }
-
clean has no relation to terminate(). After terminate just wait for few seconds to ensure that thread is really gone. Look at the documentation on why should you avoid terminate(...)
-
Hi,
To add to @dheerendra terminate is also a "last resort" option, it literally kills the thread. You should rather have a mechanism to stop it gracefully.
-
@R_Irudezu said in Why we should use 'clean':
Why i should avoid terminate the threads?
You find the answer in the documentation: http://doc.qt.io/qt-5/qthread.html#terminate