diff options
| author | Kent Hansen <kent.hansen@nokia.com> | 2012-04-26 10:43:07 +0200 |
|---|---|---|
| committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-01 08:21:22 +0200 |
| commit | f98e56356b932388b8e6da0802c6225710511709 (patch) | |
| tree | 21d60c6b046b34a5570b5d7baae733f6eca5b5cb /src/script | |
| parent | 8879cbba5915a60ed8b655169cfc8068802499bb (diff) | |
| download | qtscript-f98e56356b932388b8e6da0802c6225710511709.tar.gz | |
Port qtscript to QMetaMethod-based connectNotify()
The const char *-based API is deprecated and will be removed in Qt5.
Also improve the autotest so we check precisely the number of
connect/disconnect notifications received.
The hacks to manually call the notify functions aren't needed
anymore, because the internal QMetaObject::(dis)connect() now does
it for us.
Change-Id: I2e5efed34ee1cba0aad8e60ea00dc9bc2a25bc6c
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/script')
| -rw-r--r-- | src/script/bridge/qscriptqobject.cpp | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index c33cf71..ca2f4c6 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -110,15 +110,6 @@ struct QObjectConnection } }; -class QObjectNotifyCaller : public QObject -{ -public: - void callConnectNotify(const char *signal) - { connectNotify(signal); } - void callDisconnectNotify(const char *signal) - { disconnectNotify(signal); } -}; - class QObjectConnectionManager: public QObject { Q_OBJECT_FAKE @@ -2207,14 +2198,8 @@ bool QObjectConnectionManager::addSignalHandler( QVector<QObjectConnection> &cs = connections[signalIndex]; int absSlotIndex = slotCounter + metaObject()->methodOffset(); bool ok = QMetaObject::connect(sender, signalIndex, this, absSlotIndex, type); - if (ok) { + if (ok) cs.append(QObjectConnection(slotCounter++, receiver, function, senderWrapper)); - QMetaMethod signal = sender->metaObject()->method(signalIndex); - QByteArray signalString; - signalString.append('2'); // signal code - signalString.append(signal.methodSignature()); - static_cast<QObjectNotifyCaller*>(sender)->callConnectNotify(signalString); - } return ok; } @@ -2230,14 +2215,8 @@ bool QObjectConnectionManager::removeSignalHandler( if (c.hasTarget(receiver, slot)) { int absSlotIndex = c.slotIndex + metaObject()->methodOffset(); bool ok = QMetaObject::disconnect(sender, signalIndex, this, absSlotIndex); - if (ok) { + if (ok) cs.remove(i); - QMetaMethod signal = sender->metaObject()->method(signalIndex); - QByteArray signalString; - signalString.append('2'); // signal code - signalString.append(signal.methodSignature()); - static_cast<QScript::QObjectNotifyCaller*>(sender)->callDisconnectNotify(signalString); - } return ok; } } |
