There are many multithreaded Qt tutorials that indicate that QThreadyou can safely stop using the following two lines.
qthread.quit();
qthread.wait();
I have a lot of code, and in most cases when the thread stops, I always set my own cancel flag and often check it at runtime (like the norm). Until now, I thought that calling quit could cause the thread to simply stop executing any wait signals (for example, signals that are queued will no longer call their slots), but still wait for the current executable slot to finish .
But I wonder if I was right or if it quit()actually stops the thread from executing where it is, for example, if something is unfinished, like the file descriptor was not closed, this should definitely be, although in most cases my work objects will clear these resources , I would be better if I knew exactly how to stop work.
I ask this because the documentation QThread::quit()says that this is equivalent to calling QThread :: exit (0). "I believe this means that the thread will immediately stop where it is. But what happens to the higher stack structure?
source
share