[Qt-interest] QFutureIterator::next() not blocking?

Stephen Chu stephen at ju-ju.com
Thu Oct 22 21:52:15 CEST 2009


Hi

I am using QtConcurrent::mapped() and QFutureIterator to get the 
results. Something like the code below:

static int funWithList(const int & i)
{
   QThread::currentThread()->wait(10000);
   return i;
}

int main(int argc, char *argv[])
{
   QVector<int>   list;
   list.push_back(1);
   QFuture<int>   f = QtConcurrent::mapped(list, funWithList);
   QFutureIterator<int> i(f);
   while(i.hasNext()) {
      qDebug() << i.next();
      qDebug() << "Hi!";
   }
   ...
}

I get Stopped: "signal-received" in Creator when trying to debug this 
and the offending code is right at the i.next() line. The function 
funWithList is not even called yet.

I thought QFutureIterator::next() will block until the next result is 
available. Is there something extra I need to do the make it work?

Also. Are the results in QFuture always in the same sequence as the 
input list or are they in the order they are finished?

Thanks.

-- 
Stephen Chu



More information about the Qt-interest-old mailing list