QObject send signal twice(inside the QMetaObject::activate function ) in Qt5
-
I have defined a signal and connect it to a slot. I found that the slot would be invoked twice and I trace into the Qt source code.
It seems that the QMetaObject::activate will call QAbstractDeclarativeData::signalEmitted() to relay the signal from working thread to main thread (PS. I have call setContextProperty to export my object into QML engine, so it will call the signalEmitted() function):@void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_index, void **argv)
{
int signal_index = signalOffset + local_signal_index;if (sender->d_func()->declarativeData && QAbstractDeclarativeData::signalEmitted)
QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv);
@
And the following code in the QMetaObject::activate() will also call queued_activate to cause one signal be post into message queue twice.@if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread)
|| (c->connectionType == Qt::QueuedConnection)) {
queued_activate(sender, signal_index, c, argv ? argv : empty_argv);
continue;@ -
-
I'll make sure that somebody who can will, then. Thanks for trying!
Edit: Weird, I could comment myself, and I think you definiately should have been able to. It would be weird if you cannot actually give the information asked for because of the status "More information needed". Are you sure you were logged in?