Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1131

Subclass of `QRunnable` crash when it try to emit a signal

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.13.1
    • PySide
    • None
    • Windows

    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)
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            weiqi_chen_zy Weiqi Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes