Skip to content

Commit

Permalink
feat: Extend CSignalBlocker
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylskorych committed Dec 17, 2023
1 parent ea3f4bb commit bb009bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions GUIWidgets/QtWidgets/SignalBlocker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ CSignalBlocker::~CSignalBlocker()
Unblock();
}

void CSignalBlocker::Add(QObject* _object)
{
m_objects.push_back(_object);
m_flags.push_back(_object->blockSignals(true));
}

void CSignalBlocker::Unblock()
{
for (size_t i = 0; i < m_objects.size(); ++i)
Expand Down
3 changes: 3 additions & 0 deletions GUIWidgets/QtWidgets/SignalBlocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class CSignalBlocker
std::vector<QObject*> m_objects;
std::vector<bool> m_flags;
public:
CSignalBlocker() = default;
CSignalBlocker(QObject* _object);
CSignalBlocker(std::initializer_list<QObject*> _objects);
~CSignalBlocker();
Expand All @@ -19,5 +20,7 @@ class CSignalBlocker
CSignalBlocker& operator=(const CSignalBlocker& _other) = delete;
CSignalBlocker& operator=(CSignalBlocker&& _other) noexcept = delete;

void Add(QObject* _object);

void Unblock();
};

0 comments on commit bb009bf

Please sign in to comment.