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);

  • Hi, ~diro!

    Have you posted about it into Bug Tracker or not?

  • I you've filed a bug report please link to it here (and link to this discussion in the bug report). Thanks.

  • [quote author="Lukas Geyer" date="1340799948"]I you've filed a bug report please link to it here (and link to this discussion in the bug report). Thanks.[/quote]

    Lukas, can you attach URL?

  • The link has been already added.

  • [quote author="Lukas Geyer" date="1340802271"]The link has been already added.[/quote]

    Sorry, I've missed it.

  • I checked out the newest code in git, and this bug is gone now. But I am not sure the bug is corrected in which revision.

  • Please make a note of that in your bugreport. Otherwise you're going to waste developer's time on them chasing down a bug that does not exist.

  • It seems I cannot comment on that bug anymore.
    Maybe it is due to the bug status is "Need more information" now.

  • 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?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.