Call connectNotify when connecting with function pointer
Some objects expect connectNotify to be called in order the signal to be emitted. Change-Id: Id0460d9c2aef8f9c3618a2b62b2119a790e06f30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7c0153faf7
commit
889092504e
@ -4038,7 +4038,19 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
|
|||||||
}
|
}
|
||||||
|
|
||||||
QObjectPrivate::get(s)->addConnection(signal_index, c.data());
|
QObjectPrivate::get(s)->addConnection(signal_index, c.data());
|
||||||
return QMetaObject::Connection(c.take());
|
QMetaObject::Connection ret(c.take());
|
||||||
|
locker.unlock();
|
||||||
|
|
||||||
|
// reconstruct the signature to call connectNotify
|
||||||
|
const char *sig = senderMetaObject->d.stringdata + senderMetaObject->d.data[
|
||||||
|
reinterpret_cast<const QMetaObjectPrivate*>(senderMetaObject->d.data)->methodData
|
||||||
|
+ 5 * (signal_index - signalOffset)];
|
||||||
|
QVarLengthArray<char> signalSignature(qstrlen(sig) + 2);
|
||||||
|
signalSignature.data()[0] = char(QSIGNAL_CODE + '0');
|
||||||
|
strcpy(signalSignature.data() + 1 , sig);
|
||||||
|
s->connectNotify(signalSignature.data());
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -75,6 +75,7 @@ private slots:
|
|||||||
void findChildren();
|
void findChildren();
|
||||||
void connectDisconnectNotify_data();
|
void connectDisconnectNotify_data();
|
||||||
void connectDisconnectNotify();
|
void connectDisconnectNotify();
|
||||||
|
void connectNotifyPtr();
|
||||||
void emitInDefinedOrder();
|
void emitInDefinedOrder();
|
||||||
void customTypes();
|
void customTypes();
|
||||||
void streamCustomTypes();
|
void streamCustomTypes();
|
||||||
@ -849,6 +850,19 @@ void tst_QObject::connectDisconnectNotify()
|
|||||||
delete r;
|
delete r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QObject::connectNotifyPtr()
|
||||||
|
{
|
||||||
|
NotifyObject *s = new NotifyObject;
|
||||||
|
NotifyObject *r = new NotifyObject;
|
||||||
|
|
||||||
|
connect( (SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1 );
|
||||||
|
QCOMPARE( s->org_signal, s->nw_signal );
|
||||||
|
QCOMPARE( s->org_signal.toLatin1(), QMetaObject::normalizedSignature(SIGNAL(signal1())));
|
||||||
|
|
||||||
|
delete s;
|
||||||
|
delete r;
|
||||||
|
}
|
||||||
|
|
||||||
class SequenceObject : public ReceiverObject
|
class SequenceObject : public ReceiverObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user