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

Add official RAII helper classes for enabling/disabling signals

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P4: Low
    • 5.3.0
    • 5.0.0
    • Core: Object Model
    • None

    Description

      In any project I work on, I have to bring over (or re-define) custom RAII helper classes for managing Qt state in an exception-safe/early-return-safe manor.

      This is particularly true of blockSignals(true/false) which I have to use often to avoid self-notification issues.

      I have had to do this many times.

      It would be much appreciated if such helper classes could be added to the official Qt package.

      Something like:

      {
      QBlockSignals blocker(widget); // widget->blockSignals(true)
      // widget's signals are blocked
      // some code that must not cause signals to be emitted
      } // blocker destructs and calls widget->blockSignals(false)

      Similar classes could be added to block expensive updates etc.

      Note that it is important to check the state of the managed object before acting on it; if QBlockSignals above is used on an object that is already blocked, it must do nothing. Else the destructor could leave the object unblocked at an unexpected point.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            danny77uk Daniel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes