summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/statemachine/qsignaltransition.cpp29
-rw-r--r--src/corelib/statemachine/qsignaltransition_p.h3
2 files changed, 18 insertions, 14 deletions
diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp
index 4caa917..9ffcb9c 100644
--- a/src/corelib/statemachine/qsignaltransition.cpp
+++ b/src/corelib/statemachine/qsignaltransition.cpp
@@ -118,19 +118,20 @@ QSignalTransitionPrivate *QSignalTransitionPrivate::get(QSignalTransition *q)
return q->d_func();
}
-void QSignalTransitionPrivate::invalidate()
+void QSignalTransitionPrivate::unregister()
{
Q_Q(QSignalTransition);
- if (signalIndex != -1) {
- QState *source = sourceState();
- QStatePrivate *source_d = QStatePrivate::get(source);
- QStateMachinePrivate *mach = QStateMachinePrivate::get(source_d->machine());
- if (mach) {
- mach->unregisterSignalTransition(q);
- if (mach->configuration.contains(source))
- mach->registerSignalTransition(q);
- }
- }
+ if ((signalIndex == -1) || !machine())
+ return;
+ QStateMachinePrivate::get(machine())->unregisterSignalTransition(q);
+}
+
+void QSignalTransitionPrivate::maybeRegister()
+{
+ Q_Q(QSignalTransition);
+ if (!machine() || !machine()->configuration().contains(sourceState()))
+ return;
+ QStateMachinePrivate::get(machine())->registerSignalTransition(q);
}
/*!
@@ -193,8 +194,9 @@ void QSignalTransition::setSenderObject(QObject *sender)
Q_D(QSignalTransition);
if (sender == d->sender)
return;
+ d->unregister();
d->sender = sender;
- d->invalidate();
+ d->maybeRegister();
}
/*!
@@ -214,8 +216,9 @@ void QSignalTransition::setSignal(const QByteArray &signal)
Q_D(QSignalTransition);
if (signal == d->signal)
return;
+ d->unregister();
d->signal = signal;
- d->invalidate();
+ d->maybeRegister();
}
/*!
diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h
index a23e58c..339de63 100644
--- a/src/corelib/statemachine/qsignaltransition_p.h
+++ b/src/corelib/statemachine/qsignaltransition_p.h
@@ -66,7 +66,8 @@ public:
static QSignalTransitionPrivate *get(QSignalTransition *q);
- void invalidate();
+ void unregister();
+ void maybeRegister();
QObject *sender;
QByteArray signal;