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

blockSignals permits signals to be emitted

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • None
    • 6.9.0
    • Core: Other
    • None
    • Windows

    Description

      I have a checkbox that gets set from a signal from another class.  I disable signals with blockSignals(true) set the check box, then call blockSignals(false) to allow signals again.  The toggled signal is still received when the setChecked call is made.  

          connect(_framingModeCheckBox, &QCheckBox::toggled, this,
                  [this](bool checked)
                  {
                    // this signal is received from setChecked, even though signals are blocked
                      __debugbreak();
                  });
          connect(_photoViewer, &PhotoViewer::signalFramingModeEnable, this,
                  [this](bool checked)
                  {
                      blockSignals(true);
                      // sends out a toggle, also
                      _framingModeCheckBox->setChecked(checked);
                      blockSignals(false);
                  });
      void QAbstractButtonPrivate::emitToggled(bool checked)
      {
          Q_Q(QAbstractButton);
          QPointer<QAbstractButton> guard(q);
          emit q->toggled(checked);         <----- This signal is serviced even when blocked
      .
      .
      .
      } 

      Attached is an example that reproduces the issue.  In Visual Studio,  compile and run the project.  Hit the "Send Signal" button.  The PhotoViewer class will issue a signal to set the checkbox mentioned above.  _{}debugbreak{_}  is called if the toggled signal is received when blocked.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            doug_rogers Doug Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes