Reputation: 396
I'm writing a launcher for Minecraft (see full code here: http://pastie.org/6633420), which I know is a game, but it's still fun to program for.
At the moment, I am having issues with threading with QThread because all the threads seem to close before they should. I'm getting the error: QThread: Destroyed while thread is still running
. Is there any way to fix this besides doing what I did earlier in the code which was
for i in range(1,50):
QThread.msleep(200)
QCoreApplication.processEvents()
because I'm sure it really bad practice and does not work well, as it causes the application to be unresponsive at some points.
Upvotes: 2
Views: 947
Reputation: 5760
This is actually a sort of bug in the Python bindings for Qt. QThread
s instantiated inside of a function (MainWidget.update_software
, in your case) are garbage collected when the function returns, which causes the execution to end early with the QThread: Destroyed while thread is still running
message.
To solve this problem, there are two options:
.wait()
on a thread inside a function so the thread can finish processing before the function returns. This will block the main thread however, which is probably not what you want.Upvotes: 7