summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2012-09-24 12:25:49 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-26 20:45:20 +0200
commitb66b145633e19a7f70aade0943e0c8efb5169a59 (patch)
tree7effd30faa99b445d33dd625da8677ef89da391a /src/corelib/kernel
parentdff8dd6c31e81269b99004d9fb4127cd50a86fe4 (diff)
Include the signal code in the argument of (dis)connectNotify().
As it turns out, the convention of (dis)connectNotify() is to include the signal prefix, i.e. '2'. Therefore add this prefix also when calling these functions from QML. Also add a unit test confirming that the C++ and QML cases are now handled the same way. This patch is not needed in Qt5, as connectNotify() and disconnectNotify() take a QMetaMethod as a parameter, not a const char*. Change-Id: I3add0fc13c60a479949cf3d31218af5fd3f546a2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp14
-rw-r--r--src/corelib/kernel/qobject_p.h12
2 files changed, 15 insertions, 11 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index a7c3b6e3ff..bb5effc40d 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -2692,11 +2692,7 @@ 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 signalSignature = QObjectPrivate::signalSignature(signal);
{
QByteArray methodSignature;
@@ -2985,13 +2981,9 @@ 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());
- }
+ if (signal.mobj)
+ signalSignature = QObjectPrivate::signalSignature(signal);
{
QByteArray methodSignature;
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index c7aa683bd5..e2e24a61f2 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -61,6 +61,7 @@
#include "QtCore/qvector.h"
#include "QtCore/qreadwritelock.h"
#include "QtCore/qvariant.h"
+#include "QtCore/qmetaobject.h"
QT_BEGIN_NAMESPACE
@@ -184,6 +185,8 @@ public:
inline void connectNotify(const char *signal);
inline void disconnectNotify(const char *signal);
+ static inline QByteArray signalSignature(const QMetaMethod &signal);
+
public:
QString objectName;
ExtraData *extraData; // extra data set by the user
@@ -244,6 +247,15 @@ inline void QObjectPrivate::disconnectNotify(const char *signal)
q_ptr->disconnectNotify(signal);
}
+inline QByteArray QObjectPrivate::signalSignature(const QMetaMethod &signal)
+{
+ QByteArray result;
+ result.reserve(qstrlen(signal.signature())+1);
+ result.append((char)(QSIGNAL_CODE + '0'));
+ result.append(signal.signature());
+ return result;
+}
+
inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver,
Sender *sender)
{