summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-05-28 09:53:15 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-05-28 09:56:08 (GMT)
commit218c9883f5b1f7e7eb9e6272460223088bfaf305 (patch)
treedab3ee50f360bcca0b3a10b1ef0924ea3b70c250 /src/corelib/statemachine
parent4b45c38a19145f5235d93fa9d1577615cdfc162e (diff)
downloadQt-218c9883f5b1f7e7eb9e6272460223088bfaf305.zip
Qt-218c9883f5b1f7e7eb9e6272460223088bfaf305.tar.gz
Qt-218c9883f5b1f7e7eb9e6272460223088bfaf305.tar.bz2
QStateMachine: better way to get the sender signalIndex
The QObject internals have changed, and the mutex that need to be locked to access the senders list is not the same anymore, and not accessible form qstatemachine.cpp But we do not need to loop over the senders list anyway because this is done in sender() We also do not need to lock in order to access the currentSender Reviewed-by: Eskil
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 185fb7d..84619d7 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1301,22 +1301,6 @@ void QStateMachinePrivate::unregisterTransition(QAbstractTransition *transition)
#endif
}
-static int senderSignalIndex(const QObject *sender)
-{
- QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject*>(sender));
- QMutexLocker(&d->threadData->mutex);
- if (!d->currentSender)
- return -1;
-
- // Return -1 if d->currentSender isn't in d->senders
- bool found = false;
- for (int i = 0; !found && i < d->senders.count(); ++i)
- found = (d->senders.at(i)->sender == d->currentSender->sender);
- if (!found)
- return -1;
- return d->currentSender->signal;
-}
-
void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transition)
{
Q_Q(QStateMachine);
@@ -2087,10 +2071,15 @@ int QSignalEventGenerator::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
switch (_id) {
case 0: {
// ### in Qt 4.6 we can use QObject::senderSignalIndex()
- int signalIndex = senderSignalIndex(this);
+ QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr);
+ int signalIndex = -1;
+ QObject *sender = this->sender();
+ if (sender && d->currentSender)
+ signalIndex = d->currentSender->signal;
+
Q_ASSERT(signalIndex != -1);
QStateMachine *machine = qobject_cast<QStateMachine*>(parent());
- QStateMachinePrivate::get(machine)->handleTransitionSignal(sender(), signalIndex, _a);
+ QStateMachinePrivate::get(machine)->handleTransitionSignal(sender, signalIndex, _a);
break;
}
default: ;