diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index d00f8cf761..b0213efa19 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -174,6 +174,7 @@ void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = 0; int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = 0; +bool (*QAbstractDeclarativeData::isSignalConnected)(QAbstractDeclarativeData *, const QObject *, int) = 0; QObjectData::~QObjectData() {} @@ -2182,14 +2183,14 @@ int QObject::receivers(const char *signal) const return 0; } + if (!d->isSignalConnected(signal_index)) + return receivers; + if (d->declarativeData && QAbstractDeclarativeData::receivers) { receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this, signal_index); } - if (!d->isSignalConnected(signal_index)) - return receivers; - QMutexLocker locker(signalSlotLock(this)); if (d->connectionLists) { if (signal_index < d->connectionLists->count()) { @@ -3285,13 +3286,13 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i { int signal_index = signalOffset + local_signal_index; + if (!sender->d_func()->isSignalConnected(signal_index)) + return; // nothing connected to these signals, and no spy + if (sender->d_func()->declarativeData && QAbstractDeclarativeData::signalEmitted) QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv); - if (!sender->d_func()->isSignalConnected(signal_index)) - return; // nothing connected to these signals, and no spy - if (sender->d_func()->blockSig) return; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 02c9ac61a7..0d491a2b87 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -92,6 +92,7 @@ public: static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *); static void (*signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **); static int (*receivers)(QAbstractDeclarativeData *, const QObject *, int); + static bool (*isSignalConnected)(QAbstractDeclarativeData *, const QObject *, int); }; class Q_CORE_EXPORT QObjectPrivate : public QObjectData @@ -224,6 +225,8 @@ inline bool QObjectPrivate::isSignalConnected(uint signal_index) const { return signal_index >= sizeof(connectedSignals) * 8 || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f)) + || (declarativeData && QAbstractDeclarativeData::isSignalConnected + && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index)) || qt_signal_spy_callback_set.signal_begin_callback || qt_signal_spy_callback_set.signal_end_callback); }