diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-06-18 12:53:23 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-06-18 13:54:13 (GMT) |
commit | 49831f30f58d08a360d5947ba300aa3a3575d1fa (patch) | |
tree | 278134bc1f0722f5752e8c83d96d4e9e7c8d91e5 | |
parent | 4a2ba043ed09375e4d9423def32084ab97ea560a (diff) | |
download | Qt-49831f30f58d08a360d5947ba300aa3a3575d1fa.zip Qt-49831f30f58d08a360d5947ba300aa3a3575d1fa.tar.gz Qt-49831f30f58d08a360d5947ba300aa3a3575d1fa.tar.bz2 |
Make QObject::connect with QMetaMethod works with Jambi
We need to call QInternal::activateCallbacks to the recently added
overload of QObject::connect
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index dff282e..ad689ca 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2644,7 +2644,6 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) { - #ifndef QT_NO_DEBUG bool warnCompat = true; #endif @@ -2667,6 +2666,24 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, return false; } + // Reconstructing SIGNAL() macro result for signal.signature() string + QByteArray signalSignature; + signalSignature.reserve(qstrlen(signal.signature())+1); + signalSignature.append((char)(QSIGNAL_CODE + '0')); + signalSignature.append(signal.signature()); + + { + QByteArray methodSignature; + methodSignature.reserve(qstrlen(method.signature())+1); + methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE + : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0')); + methodSignature.append(method.signature()); + const void *cbdata[] = { sender, signalSignature.constData(), receiver, methodSignature.constData(), &type }; + if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata)) + return true; + } + + int signal_index; int method_index; { @@ -2707,11 +2724,6 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, #endif if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types)) return false; - // Reconstructing SIGNAL() macro result for signal.signature() string - QByteArray signalSignature; - signalSignature.reserve(qstrlen(signal.signature())+1); - signalSignature.append((char)(QSIGNAL_CODE + '0')); - signalSignature.append(signal.signature()); const_cast<QObject*>(sender)->connectNotify(signalSignature.constData()); return true; @@ -2947,6 +2959,28 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, } } + // Reconstructing SIGNAL() macro result for signal.signature() string + QByteArray signalSignature; + if (signal.mobj) { + signalSignature.reserve(qstrlen(signal.signature())+1); + signalSignature.append((char)(QSIGNAL_CODE + '0')); + signalSignature.append(signal.signature()); + } + + { + QByteArray methodSignature; + if (method.mobj) { + methodSignature.reserve(qstrlen(method.signature())+1); + methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE + : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0')); + methodSignature.append(method.signature()); + } + const void *cbdata[] = { sender, signal.mobj ? signalSignature.constData() : 0, + receiver, method.mobj ? methodSignature.constData() : 0 }; + if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata)) + return true; + } + int signal_index; int method_index; { @@ -2970,16 +3004,8 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, if (!QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index)) return false; - if (!signal.mobj) { - const_cast<QObject*>(sender)->disconnectNotify(0); - } else { - // Reconstructing SIGNAL() macro result for signal.signature() string - QByteArray signalSignature; - signalSignature.reserve(qstrlen(signal.signature())+1); - signalSignature.append((char)(QSIGNAL_CODE + '0')); - signalSignature.append(signal.signature()); - const_cast<QObject*>(sender)->disconnectNotify(signalSignature.constData()); - } + + const_cast<QObject*>(sender)->disconnectNotify(method.mobj ? signalSignature.constData() : 0); return true; } |