]> git.lyx.org Git - lyx.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>
Fri, 26 Aug 2016 19:42:52 +0000 (20:42 +0100)
(cherry picked from commit bc8eb059db9f25b0cb44af0a26fba13170971f40)

src/frontends/qt4/qt_helpers.h

index d4afc78a338b7e615729a6debd1a377a4d5391e4..f0a9a11d8e33818ec722ec495c794bf6fa18d432 100644 (file)
@@ -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