Will the finished()
signal of QFutureWatcher
always be fired, even if the concurrent job that the QFuture
represents has completed before the QFutureWatcher
is attached to the QFuture
?
Consider the following example:
// Start some computation.
QFuture<int> future = QtConcurrent::run(...);
// [A] At this point some time may pass where the computation might finish concurrently
// Instaciate watcher
QFutureWatcher<int> watcher;
// Instantiate an object to receive singal
MyClass myObject;
// Connect slot to watcher's finished() signal
connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished()));
// Attach watcher to the future
watcher.setFuture(future);
// [B] Will the handleFinished() slot be called at this point even if the concurrent job already completed in point [A] above?
And, most importantly, if this does not happen, how can I make the handleFinished()
slot always be called in this case?