]> git.lyx.org Git - features.git/commitdiff
Basic implementation of QSignalBlocker for qt4
authorGuillaume Munch <gm@lyx.org>
Fri, 29 Jul 2016 20:18:43 +0000 (21:18 +0100)
committerGuillaume Munch <gm@lyx.org>
Sun, 31 Jul 2016 17:34:33 +0000 (18:34 +0100)
src/frontends/qt4/qt_helpers.h

index 9f239a8131ff594e9a59b92f5c88cddfc9a0347e..5574212c26382cfba5f965e7a1b5677c8cc56e25 100644 (file)
@@ -213,6 +213,24 @@ QString guiName(std::string const & type, BufferParams const & bp);
 QString formatToolTip(QString text, int width = 30);
 
 
+#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