Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.0.0 Beta 1
-
Windows 7 64bit, MSVC10
Description
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;