From 2da2f6c00c4ef9b88e769f18234c4d0400997ea1 Mon Sep 17 00:00:00 2001 From: Guillaume Munch Date: Fri, 29 Jul 2016 21:18:43 +0100 Subject: [PATCH] Basic implementation of QSignalBlocker for qt4 (cherry picked from commit bc8eb059db9f25b0cb44af0a26fba13170971f40) --- src/frontends/qt4/qt_helpers.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/frontends/qt4/qt_helpers.h b/src/frontends/qt4/qt_helpers.h index d4afc78a33..f0a9a11d8e 100644 --- a/src/frontends/qt4/qt_helpers.h +++ b/src/frontends/qt4/qt_helpers.h @@ -195,6 +195,24 @@ QString changeExtension(QString const & oldname, QString const & ext); /// parameter. QString guiName(std::string const & type, BufferParams const & bp); +#if QT_VERSION < 0x050300 +// Very partial implementation of QSignalBlocker for archaic qt versions. +class QSignalBlocker { +public: + explicit QSignalBlocker(QObject * o) + : obj(o), init_state(obj && obj->blockSignals(true)) {} + + ~QSignalBlocker() { + if (obj) + obj->blockSignals(init_state); + } +private: + QObject * obj; + bool init_state; +}; +#endif + + } // namespace lyx #endif // QTHELPERS_H