[Interest] Passing constructor arguments to an object that is to be run on a separate thread
d3faultdotxbe at gmail.com
Thu Nov 15 23:44:31 CET 2012
tl;dr: we should stop teaching QObject::moveToThread as the recommended qt
reason: you can't safely use the same object in same-thread use and
multi-thread use. it requires a special thread-aware object or glue code
the [non auto-generated] QThread::run method also sucks because the _user_
will end up making a ton of useless QThread subclasses
i propose more hackery. a moc hack, to be specific (because a preprocessor
macro can't have Q_OBJECT in it)
what is a PORTABLE way to save arguments (as
auto-generated/invisible-to-user QThread subclass *constructor*
argument(s)) to be passed in during the "object" instantiation/construction
args from inside QThread::run?
1) implitly shared reference count being 3 instead of 2
2) pointers becoming null before QThread::run is active
3) tons of other scenarios i am probably missing
Is Q_ARG/QGenericArgument what I want? Or should I steal the code from
however signals/slots does it?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest