diff --git a/src/libcalamares/utils/RAII.h b/src/libcalamares/utils/RAII.h index dae85e84a..28e57ff9e 100644 --- a/src/libcalamares/utils/RAII.h +++ b/src/libcalamares/utils/RAII.h @@ -1,5 +1,5 @@ /* === This file is part of Calamares - === - * + * * SPDX-FileCopyrightText: 2020 Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify @@ -24,6 +24,7 @@ #define UTILS_RAII_H #include +#include #include @@ -44,4 +45,21 @@ struct cqDeleter } }; +/// @brief Sets a bool to @p value and resets to !value on destruction +template < bool value > +struct cBoolSetter +{ + bool& m_b; + + cBoolSetter( bool& b ) + : m_b( b ) + { + m_b = value; + } + ~cBoolSetter() { m_b = !value; } +}; + +/// @brief Blocks signals on a QObject until destruction +using cSignalBlocker = QSignalBlocker; + #endif