[PySide] Segfault using QScxmlStateMachine.submitEvent(QScxmlEvent)

Romain LE DISEZ romain at ledisez.net
Thu Nov 8 21:30:53 CET 2018

Hi all,

I'm very new to Qt as I'm developing my first application with it. I'm trying to use StateChart based on QScxmlStateMachine.

It works fine except in a situation where I get a segfault. If, in the demo code below, you comment the line submitEvent('MY_EVENT') and uncomment the usage of a ScxmlEvent, the event is dispatched then the application segfaults. Output is:
    StateMachine::active: True
    ('MY_EVENT:', (), {})
    Segmentation fault: 11

Am I doing something wrong or is it a bug? How can I provide you useful informations in the latter case. I'm running PySide2 (v5.11.2) on macOS (High Sierra) with Python v2.7.15 (coming from brew).

Thx for your help.

    <?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"/>

    #!/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()'))

        def state_machine_active(self, active):
            print('StateMachine::active: %s' % active)
            #ev = QScxmlEvent()

        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)



More information about the PySide mailing list