On 8 May 2018 at 04:12, Giuseppe D'Angelo <giuseppe.dang...@kdab.com> wrote: > Il 07/05/2018 20:24, Christian Ehrlicher ha scritto: >> >> I did not found a hint int the documentation about this behavior. >> Therefore my question - should this work for a queued connection or not? >> At least msvc2017 and gcc 4.8 don't like it when compiling with -O2... > > > The documentation doesn't talk about QArgument, but about Q_ARG and > Q_RETURN_ARG, which is what you should use. > > (Under the hood, the problem is that QArgument simply stores a pointer to > your variable. If that variable is a temporary, that pointer becomes > immediately dangling. For this reason, do not store what Q_ARG builds, e.g. > in an variable declared auto!)
>From Qt 5.10 onwards, we can even do without Q_ARG (and QArgument). Pass a function pointer or lambda expression to QMetaObject::invokeMethod(). Regards, Sze-Howe _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest