From: Peter Kümmel Date: Sat, 23 Oct 2010 00:06:22 +0000 (+0000) Subject: bind makes a copy of the arguments by default. This is secure if the X-Git-Tag: 2.0.0~2290 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ad51a8e88e3d9afac5ed354d0d5adb656e692c02;p=lyx.git bind makes a copy of the arguments by default. This is secure if the bound object survives the existance of the arguments, but it also breaks "change by non-const reference" parameter passing, like in Alert::askForString. Here the arguments exists the whole bound function call so we could pass by refernce. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35789 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/InGuiThread.h b/src/frontends/qt4/InGuiThread.h index 764169f8b2..4939c64726 100644 --- a/src/frontends/qt4/InGuiThread.h +++ b/src/frontends/qt4/InGuiThread.h @@ -63,27 +63,27 @@ public: } template - R call(F f, P1 p1) + R call(F f, P1& p1) { - return call(bind(f, p1)); + return call(bind(f, ref(p1))); } template - R call(F f, P1 p1, P2 p2) + R call(F f, P1& p1, P2& p2) { - return call(bind(f, p1, p2)); + return call(bind(f, ref(p1), ref(p2))); } template - 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(bind(f, ref(p1), ref(p2), ref(p3))); } template - 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(bind(f, ref(p1), ref(p2), ref(p3), ref(p4))); } /* @@ -91,9 +91,9 @@ public: */ template - 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(bind(f, ref(p1), ref(p2), ref(p3), ref(p4), ref(p5), ref(p6), ref(p7), ref(p8))); } private: @@ -125,27 +125,27 @@ public: } template - void call(F f, P1 p1) + void call(F f, P1& p1) { - call(bind(f, p1)); + call(bind(f, ref(p1))); } template - void call(F f, P1 p1, P2 p2) + void call(F f, P1& p1, P2& p2) { - call(bind(f, p1, p2)); + call(bind(f, ref(p1), ref(p2))); } template - 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(bind(f, ref(p1), ref(p2), ref(p3))); } template - 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(bind(f, ref(p1), ref(p2), ref(p3), ref(p4))); } /* @@ -153,9 +153,9 @@ public: */ template - 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, ref(p1), ref(p2), ref(p3), ref(p4), ref(p5), ref(p6), ref(p7), ref(p8))); } private: