Add QAbstractDeclarativeData::isSignalConnected hook
Similar to QAbstractDeclarative::receivers. This hook will allow QObject::isSignalConnected(QMetaMethod) to return true when there are QML-managed connections. It's important that the hook is called from QObjectPrivate::isSignalConnected(uint), since QML calls that function. Change-Id: I9c5e42f2b3e7f985af02905985a3a47101cdee05 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
This commit is contained in:
parent
744a31fe2a
commit
f4b3fa305d
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user