diff options
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 8 | ||||
-rw-r--r-- | src/corelib/kernel/qobject_p.h | 21 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeboundsignal.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativenotifier_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeproperty.cpp | 4 |
5 files changed, 27 insertions, 14 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8961e34..9008fb8 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -54,7 +54,6 @@ #include <qdebug.h> #include <qhash.h> #include <qpair.h> -#include <qvarlengtharray.h> #include <qset.h> #include <qsemaphore.h> #include <qsharedpointer.h> @@ -2692,7 +2691,8 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, return false; } - QByteArray signalSignature = QObjectPrivate::signalSignature(signal); + QVarLengthArray<char> signalSignature; + QObjectPrivate::signalSignature(signal, &signalSignature); { QByteArray methodSignature; @@ -2981,9 +2981,9 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, } } - QByteArray signalSignature; + QVarLengthArray<char> signalSignature; if (signal.mobj) - signalSignature = QObjectPrivate::signalSignature(signal); + QObjectPrivate::signalSignature(signal, &signalSignature); { QByteArray methodSignature; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 6521a4f..7c56f63 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -62,6 +62,7 @@ #include "QtCore/qreadwritelock.h" #include "QtCore/qvariant.h" #include "QtCore/qmetaobject.h" +#include "QtCore/qvarlengtharray.h" QT_BEGIN_NAMESPACE @@ -185,7 +186,8 @@ public: inline void connectNotify(const char *signal); inline void disconnectNotify(const char *signal); - static inline QByteArray signalSignature(const QMetaMethod &signal); + static inline void signalSignature(const QMetaMethod &signal, + QVarLengthArray<char> *result); public: QString objectName; @@ -247,13 +249,18 @@ inline void QObjectPrivate::disconnectNotify(const char *signal) q_ptr->disconnectNotify(signal); } -inline QByteArray QObjectPrivate::signalSignature(const QMetaMethod &signal) +inline void QObjectPrivate::signalSignature(const QMetaMethod &signal, + QVarLengthArray<char> *result) { - QByteArray result; - result.reserve(qstrlen(signal.signature())+1); - result.append((char)(QSIGNAL_CODE + '0')); - result.append(signal.signature()); - return result; + Q_ASSERT(result); + const int signatureLength = qstrlen(signal.signature()); + if (signatureLength == 0) { + result->append((char)0); + return; + } + result->reserve(signatureLength + 2); + result->append((char)(QSIGNAL_CODE + '0')); + result->append(signal.signature(), signatureLength + 1); } inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver, diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index d8aeef6..9bccb42 100644 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ b/src/declarative/qml/qdeclarativeboundsignal.cpp @@ -137,7 +137,9 @@ QDeclarativeBoundSignal::~QDeclarativeBoundSignal() void QDeclarativeBoundSignal::disconnect() { QObjectPrivate * const priv = QObjectPrivate::get(m_scope); - priv->disconnectNotify(QObjectPrivate::signalSignature(m_signal)); + QVarLengthArray<char> signalSignature; + QObjectPrivate::signalSignature(m_signal, &signalSignature); + priv->disconnectNotify(signalSignature.constData()); } int QDeclarativeBoundSignal::index() const diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h index 0e38ec1..f15efb6 100644 --- a/src/declarative/qml/qdeclarativenotifier_p.h +++ b/src/declarative/qml/qdeclarativenotifier_p.h @@ -217,7 +217,9 @@ void QDeclarativeNotifierEndpoint::disconnect() QMetaObject::disconnectOne(s->source, s->sourceSignal, target, targetMethod); QObjectPrivate * const priv = QObjectPrivate::get(s->source); const QMetaMethod signal = s->source->metaObject()->method(s->sourceSignal); - priv->disconnectNotify(QObjectPrivate::signalSignature(signal)); + QVarLengthArray<char> signalSignature; + QObjectPrivate::signalSignature(signal, &signalSignature); + priv->disconnectNotify(signalSignature.constData()); s->source = 0; } } else if (type == NotifierType) { diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index e6b9775..ce4122a 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1634,7 +1634,9 @@ bool QDeclarativePropertyPrivate::connect(QObject *sender, int signal_index, const QMetaMethod signal = sender->metaObject()->method(signal_index); QObjectPrivate * const senderPriv = QObjectPrivate::get(sender); - senderPriv->connectNotify(QObjectPrivate::signalSignature(signal)); + QVarLengthArray<char> signalSignature; + QObjectPrivate::signalSignature(signal, &signalSignature); + senderPriv->connectNotify(signalSignature.constData()); return QMetaObject::connect(sender, signal_index, receiver, method_index, type, types); } |