]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/InGuiThread.h
Use the command-alternatives sequence as defined in menus.bind
[lyx.git] / src / frontends / qt4 / InGuiThread.h
index 6d3b778a04eafb924bad289925c3d9620f225d94..2b0d4dfe37fe01076c498461e2e0a343b1909d0f 100644 (file)
@@ -12,7 +12,9 @@
 #ifndef INGUITHREAD_H
 #define INGUITHREAD_H
 
+#include <QMutex>
 #include <QObject>
+#include <QWaitCondition>
 
 #include "support/bind.h"
 #include "support/functional.h"
@@ -32,14 +34,16 @@ protected:
        void callInGuiThread();
 
 Q_SIGNALS:
-       void triggerCall();
-       void called();
+       void triggerFunctionCall();
 
 private Q_SLOTS:
        void doFunctionCall();
 
 private:
        virtual void synchronousFunctionCall() = 0;
+
+       QWaitCondition condition_;
+       QMutex sync_mutex_;
 };
 
 
@@ -48,7 +52,8 @@ class InGuiThread : private IntoGuiThreadMover
 {
 public:
 
-       InGuiThread() {}
+       // please coverity by explicitly initalizing this variable.
+       InGuiThread() : return_value_(R()) {}
 
        template<class F>
        R call(F f)
@@ -59,27 +64,27 @@ public:
        }
 
        template<class F, class P1>
-       R call(F f, P1 p1)
+       R call(F f, P1& p1)
        {
-               return call(bind(f, p1));
+               return call(lyx::bind(f, lyx::ref(p1)));
        }
 
        template<class F, class P1, class P2>
-       R call(F f, P1 p1, P2 p2)
+       R call(F f, P1& p1, P2& p2)
        {
-               return call(bind(f, p1, p2));
+               return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2)));
        }
 
        template<class F, class P1, class P2, class P3>
-       R call(F f, P1 p1, P2 p2, P3 p3)
+       R call(F f, P1& p1, P2& p2, P3& p3)
        {
-               return call(bind(f, p1, p2, p3));
+               return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3)));
        }
 
        template<class F, class P1, class P2, class P3, class P4>
-       R call(F f, P1 p1, P2 p2, P3 p3, P4 p4)
+       R call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
        {
-               return call(bind(f, p1, p2, p3, p4));
+               return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4)));
        }
 
        /*
@@ -87,9 +92,10 @@ public:
        */
 
        template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
-       R call(F f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
+       R call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
        {
-               return call(bind(f, p1, p2, p3, p4, p5, p6, p7, p8));
+               return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4),
+                       lyx::ref(p5), lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
        }
 
 private:
@@ -121,27 +127,27 @@ public:
        }
 
        template<class F, class P1>
-       void call(F f, P1 p1)
+       void call(F f, P1& p1)
        {
-               call(bind(f, p1));
+               call(lyx::bind(f, lyx::ref(p1)));
        }
 
        template<class F, class P1, class P2>
-       void call(F f, P1 p1, P2 p2)
+       void call(F f, P1& p1, P2& p2)
        {
-               call(bind(f, p1, p2));
+               call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2)));
        }
 
        template<class F, class P1, class P2, class P3>
-       void call(F f, P1 p1, P2 p2, P3 p3)
+       void call(F f, P1& p1, P2& p2, P3& p3)
        {
-               call(bind(f, p1, p2, p3));
+               call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3)));
        }
 
        template<class F, class P1, class P2, class P3, class P4>
-       void call(F f, P1 p1, P2 p2, P3 p3, P4 p4)
+       void call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
        {
-               call(bind(f, p1, p2, p3, p4));
+               call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4)));
        }
 
        /*
@@ -149,9 +155,10 @@ public:
        */
 
        template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
-       void call(F f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8)
+       void call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
        {
-               call(bind(f, p1, p2, p3, p4, p5, p6, p7, p8));
+               call(bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4), lyx::ref(p5),
+                       lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
        }
 
 private:
@@ -169,4 +176,4 @@ private:
 } // namespace frontend
 } // namespace lyx
 
-#endif // GUIABOUT_H
+#endif // INGUITHREAD_H