Hi,
still got no solution for this and trying to work around this problems in all my HSM-related code. Quite annoying.
Anyhow, I unearthed some further info on the topic. Unfortunatly this make the issue even more mysterious. I found out that adding a SIGNAL() around the string in line 21 of the previous posting makes the problem disappear. Well it makes the message disappear. I then constructed some code that would help testing whether or not the state switch really occurred:
@
from PySide import QtCore, QtGui
import sys
class MyMainWindow(QtGui.QMainWindow):
test_signal1 = QtCore.Signal()
test_signal2 = QtCore.Signal(int)
test_signal3 = QtCore.Signal(str)
def init(self,parent=None):
super(MyMainWindow,self)
.init(parent)
QtCore.QTimer.singleShot(
1000,self.setupHsm)
QtCore.QTimer.singleShot(
3000,self.sendSignal)
QtCore.QTimer.singleShot(
1500,self.printConf)
QtCore.QTimer.singleShot(
3500,self.printConf)
def setupHsm(self):
self.state_machine = QtCore
.QStateMachine()
self.one_state = QtCore
.QState(self.state_machine)
self.state_machine
.setInitialState(
self.one_state)
self.other_state = QtCore
.QState(self.state_machine)
self.one_state.addTransition(self,
"test_signal1()"
,self.other_state)
self.one_state.addTransition(self,
"test_signal2(int)"
,self.other_state)
self.one_state.addTransition(self,
QtCore.SIGNAL("test_signal3(str)")
,self.other_state)
self.state_machine.start()
print self.state_machine.configuration()
def printConf(self):
print self.state_machine.configuration()
def sendSignal(self):
self.test_signal3.emit("bla")
print self.state_machine.configuration()
if name == "main":
app = QtGui.QApplication(sys.argv)
myapp = MyMainWindow()
myapp.show()
sys.exit(app.exec_())
@
What I get is this:
@
set([])
set([<PySide.QtCore.QState object at 0xa15454c>])
set([<PySide.QtCore.QState object at 0xa15454c>])
set([<PySide.QtCore.QState object at 0xa15454c>])
@
First thing I noted was the empty configuration directly after the start of the HSM (printed in line 39). That's why I introduced a method that prints the configuration and is called half a second alter. This gives a reasonable output. Apparently I need to return to the EventQueue after starting the HSM.
However after emitting test_signal3 the configuration remains unchanged. Even after returning to the EventQueue (again using a QTimer::singleShot). On the other hand when emitting test_signal2 (istead of 3) in line 45, the change in the state can be observed.
@
set([<PySide.QtCore.QState object at 0x8a1154c>])
set([<PySide.QtCore.QState object at 0x8a1156c>])
set([<PySide.QtCore.QState object at 0x8a1156c>])
@
Can anyone help. Or at least test whether the above code yields similar results?
Thanks