Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-26346

QObject send signal twice(inside the QMetaObject::activate function )

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 5.0.0 Beta 1
    • Core: Object Model
    • 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;
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            diro diro
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes