On Monday 04 March 2013 23:56:35 Thiago Macieira wrote: > On terça-feira, 5 de março de 2013 08.54.35, André Somers wrote: > > Op 5-3-2013 8:41, Thiago Macieira schreef: > > > On terça-feira, 5 de março de 2013 08.38.17, André Somers wrote: > > >> I'd appreciate a reply on the point that when using a QFutureWatcher, > > >> you don't know if the future is already done or not at the moment you > > >> connect. > > > > > > It's not done, by construction. > > > > So, if I understand you correctly, the following is completely safe right? > > > > QFuture<void> future = QtConcurrent::run(someFunction, 42, "blah"); > > //... perhaps some code, but not returning to the event loop > > QFutureWatcher* watcher = new QFutureWatcher(this); > > watcher.setFuture(future); > > connect(watcher, SIGNAL(finished(), this, > > SLOT(resultOfSomeFunctionReady())); > > Yes.
No. If you do that, there is even a qWarning telling you there will be a race: http://code.woboq.org/qt5/qtbase/src/corelib/thread/qfuturewatcher.cpp.html#_ZN18QFutureWatcherBase13connectNotifyERK11QMetaMethod You should setup the connection before the future. -- Olivier Woboq - Qt services and support - http://woboq.com - http://code.woboq.org _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
