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

Segfault using QScxmlStateMachine.submitEvent(QScxmlEvent)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.11.2
    • Fix Version/s: 5.12.0
    • Component/s: PySide
    • Labels:
      None
    • Platform/s:
      macOS
    • Commits:
      830fb5792ae7825c4cc5ab45330f39ea7567d73b (pyside/pyside-setup/5.12)

      Description

      The demo code below generates a segfault with this output:

      StateMachine::active: True
      ('MY_EVENT:', (), {})
      Segmentation fault: 11

      If you comment the usage QScxmlEvent and just use the submitEvent('MY_EVENT'), it works fine.

      demo.scxml:

      <?xml version="1.0" encoding="UTF-8"?>
      <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" binding="early" name="demo.scxml">
          <transition type="internal" event="MY_EVENT"/>
          <state id="StateMachine"/>
      </scxml>
      

      demo.py:

      #!/usr/bin/env python
      
      import sys
      
      from PySide2.QtCore import QObject, QCoreApplication, SLOT, Slot
      from PySide2.QtScxml import QScxmlStateMachine, QScxmlEvent
      
      
      class Backend(QObject):
          def __init__(self, machine):
              super(Backend, self).__init__()
              self.machine = machine
              self.machine.connectToState('StateMachine', self,
                                          SLOT('state_machine_active(bool)'))
              self.machine.connectToEvent('MY_EVENT', self, SLOT('my_event()'))
      
          @Slot(bool)
          def state_machine_active(self, active):
              print('StateMachine::active: %s' % active)
              #self.machine.submitEvent('MY_EVENT')
              ev = QScxmlEvent()
              ev.setName('MY_EVENT')
              ev.setEventType(QScxmlEvent.ExternalEvent)
              self.machine.submitEvent(ev)
      
          @Slot()
          def my_event(self, *args, **kwargs):
              print('MY_EVENT:', args, kwargs)
      
      
      if __name__ == '__main__':
          app = QCoreApplication(sys.argv)
      
          machine = QScxmlStateMachine.fromFile('demo.scxml')
          b = Backend(machine)
          machine.start()
      
          sys.exit(app.exec_())
      

        Attachments

        1. pyside850_stack.txt
          17 kB
        2. pyside850.zip
          1 kB
        For Gerrit Dashboard: PYSIDE-850
        # Subject Branch Project Status CR V

          Activity

            People

            • Assignee:
              kleint Friedemann Kleint
              Reporter:
              rledisez Romain LE DISEZ
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes