Domanda

I have a QThread that emits finished() signal, but its isFinished() returns False. Why is that? How to know when isFinished will start to return True?

from __future__ import print_function
from PySide import QtCore, QtGui

qapp = QtGui.QApplication([])
worker_thread = QtCore.QThread()
worker_thread.start()
worker_thread.quit()

def fin():
    print('isFinished:', worker_thread.isFinished())
worker_thread.finished.connect(fin)
QtCore.QTimer.singleShot(200, qapp.quit)
qapp.exec_()

sometimes it returns true, but most of the time it outputs:

isFinished: False

answer in another SO question(QThread emits finished() signal but isRunning() returns true and isFinished() returns false) suggests that it should be like this:

  1. At this point, isFinished() should start returning true and isRunning() false.
  2. The internals emit the finished() signal.
  • py 2.7.4
  • PySide 1.1.2
  • Qt 4.8.2

also tested with PyQt4

È stato utile?

Soluzione

Turns out it was a bug in qt (https://bugreports.qt-project.org/browse/QTBUG-30251) which is fixed in Qt 4.8.5. PySide 1.2.1 comes with Qt4.8.5.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top