Details
-
Suggestion
-
Resolution: Done
-
P4: Low
-
5.0.0
-
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.