QMetaObject::invokeMethod pass custom-type called Twice custom-type's copy constructor...
-
@opengpu said in QMetaObject::invokeMethod pass custom-type called Twice custom-type's copy constructor...:
i think normally it's not safe to pass-by-reference across threads, right?
Depends who you ask. The chair of the C++ standard committee is of the opinion that as STL uses
const
as implying thread safety* the entire language should conform to that convention. In that case usingcons&
as argument is safe even across threads. On the other hand it's a jungle out there and it's very easy to break that convention so I would not bet my life on thread safety of const references*source: https://herbsutter.com/2013/01/01/video-you-dont-know-const-and-mutable/
-
@opengpu said in QMetaObject::invokeMethod pass custom-type called Twice custom-type's copy constructor...:
it's not safe to pass-by-reference across threads, right?
@SGaist already explained in this thread that the parameter is copied when using queued connection between threads, so it IS safe...