From 79cbdb503aec471cfb1dfcc7b36867490e4ca7ee Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Tue, 2 Oct 2012 09:40:42 +0200 Subject: Use QVarLengthArray when creating the connectNotify() argument This gets rid of the heap allocation of the QByteArray. This change is not needed in Qt5, as there, QMetaMethod is used as the argument, and therefore there is no need to construct a SIGNAL-compatible string in memory. Change-Id: Ie2023aeb99bc8f792d437ec604e9989a5efe456b Reviewed-by: Alan Alpert <416365416c@gmail.com> --- src/declarative/qml/qdeclarativeboundsignal.cpp | 4 +++- src/declarative/qml/qdeclarativenotifier_p.h | 4 +++- src/declarative/qml/qdeclarativeproperty.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/declarative') diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index d8aeef6fb9..9bccb42bd2 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 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 0e38ec106a..f15efb6883 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 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 e6b9775fbb..ce4122a62b 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 signalSignature; + QObjectPrivate::signalSignature(signal, &signalSignature); + senderPriv->connectNotify(signalSignature.constData()); return QMetaObject::connect(sender, signal_index, receiver, method_index, type, types); } -- cgit v1.2.3