Reputation: 12753
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.
isRunning()
or isFinished()
hung in the first place? They don't suppose to block.Upvotes: 0
Views: 123
Reputation: 12753
It seems that in some cases, the thread becomes unusable after termination, and isRunning()
and isFinished()
may hang the calling thread, even if called only after the TERMINATED
signal.
My workaround was to terminate a thread, forget about it and start a new one.
Upvotes: 0
Reputation: 69062
Don't use terminate()
, read the warning in the documentation.
Whil it is possible to restart a QThread
, restarting threads usually is not a good idea, there should be a better solution to do what you're trying to do.
Upvotes: 1