Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.13.1
-
None
Description
from PySide2.QtWidgets import * from PySide2.QtCore import * import sys class MyRunnable(QRunnable, QObject): done = Signal(str) def __init__(self, parent=None): super(MyRunnable, self).__init__(parent) def run(self): print(f"{self} run.") i=0 while i<4: QThread.currentThread().sleep(1) print(f"while {i}<4") i += 1 self.done.emit("hahahaha") class MyObject(QObject): def __init__(self, parent=None): super().__init__(parent) long_time_operator = MyRunnable() long_time_operator.setAutoDelete(True) #long_time_operator.done.connect(self.onDone, Qt.ConnectionType.QueuedConnection) long_time_operator.done.connect(self.onDone) QThreadPool.globalInstance().start(long_time_operator) @Slot(str) def onDone(self, haha): print(f"Received:{haha}") if __name__ == '__main__': app = QApplication(sys.argv) my_object = MyObject() sys.exit(app.exec_())
Here is the output of code below
<__main__.MyRunnable object at 0x0000018668838588> run. while 0<4 while 1<4 while 2<4 while 3<4 Process finished with exit code -1073741819 (0xC0000005)