[Interest] QMetaMethod::invoke / Q_ARG with a temporary

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Mon May 7 20:24:55 CEST 2018


Hi,

today I discovered that Q_QArgument does not handle a temporary 
(boolean) value as I would have expected it.
I'm invoking the method similar to this:

QArgument<bool> arg3("bool", !inProgress);
request.replySlot.invoke(m_objToInform, Qt::QueuedConnection, arg1, 
arg2, arg3);

Changing it to
bool bFinished = !inProgress;
QArgument<bool> arg3("bool", bFinished);
fixes the problem but I'm not sure if the compiler can maybe optimize it 
away...

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...

Thx,
Christian



More information about the Interest mailing list