|
ACF $AcfVersion:0$
|
RAII helper class for temporarily blocking Qt signals from QObjects. More...
#include <CSignalBlocker.h>
Public Member Functions | |
| CSignalBlocker (QObject *objectPtr, bool blockChilds=false) | |
| Constructs a signal blocker and immediately blocks signals on the specified object. | |
| virtual | ~CSignalBlocker () |
| Destroys the signal blocker and restores the previous signal blocking state. | |
RAII helper class for temporarily blocking Qt signals from QObjects.
CSignalBlocker provides an exception-safe way to temporarily block Qt signal emissions from one or more QObjects. Signals are automatically blocked in the constructor and restored to their previous state in the destructor, following the RAII (Resource Acquisition Is Initialization) pattern.
Signal blocking is useful when you need to:
Signal blocking is very lightweight and has minimal overhead. It's safe to use in performance-critical code paths. However, remember that blocked signals are simply not emitted - they are not queued or delayed.
Definition at line 130 of file CSignalBlocker.h.
| iqt::CSignalBlocker::CSignalBlocker | ( | QObject * | objectPtr, |
| bool | blockChilds = false |
||
| ) |
Constructs a signal blocker and immediately blocks signals on the specified object.
The constructor saves the current signal blocking state of the object and then blocks its signals. The previous state will be restored in the destructor.
| objectPtr | Pointer to the QObject whose signals should be blocked. If nullptr, the blocker does nothing (no-op). |
| blockChilds | If true, recursively blocks signals on all child objects as well. If false (default), only the specified object is affected. |
|
virtual |
Destroys the signal blocker and restores the previous signal blocking state.
The destructor automatically restores the signal blocking state that was active when the blocker was constructed. This ensures proper cleanup even in the presence of exceptions.