I have a QThread that fetches data from the web. Sometimes the user asks for something else, and the data needs to be fetched changes as well.
In my current configuration, I call terminate() upon the thread, change the input data, and call start() on the thread again. Now, that works fine, but sometimes I get the main eventloop stuck when calling isRunning() or isFinished() upon a terminated thread. It gets stuck forever, and does not recover until I kill the process.
- Why would
isRunning()orisFinished()hung in the first place? They don’t suppose to block. - Is this workflow acceptable? If not, how can I stop a thread’s process when I don’t need it no more (or how can I abandon it)?
It seems that in some cases, the thread becomes unusable after termination, and
isRunning()andisFinished()may hang the calling thread, even if called only after theTERMINATEDsignal.My workaround was to terminate a thread, forget about it and start a new one.