Some explanatory comments in this stuff would help, too. These complex constructions are nice in reducing code, but they are hard for novices to read without help.
rh On 06/26/2016 03:20 PM, Guillaume Munch wrote:
+namespace { + +template<typename F> +typename std::result_of<F()>::type call(F f) { +#if EXPORT_in_THREAD + return call_in_gui_thread(f); +#else + return f(); +#endif +} + +} // anon namespace + + void noAppDialog(QString const & title, QString const & msg, QMessageBox::Icon mode) { int argc = 1; @@ -136,13 +150,10 @@ int prompt(docstring const & title0, docstring const & question, docstring const & b1, docstring const & b2, docstring const & b3, docstring const & b4) { -#ifdef EXPORT_in_THREAD - return InGuiThread<int>().call(&doPrompt, -#else - return doPrompt( -#endif - title0, question, default_button, - cancel_button, b1, b2, b3, b4); + return call([&, default_button, cancel_button] () { + return doPrompt(title0, question, default_button, + cancel_button, b1, b2, b3, b4); + }); }