If the main thread goes into a wait for the worker thread before
the worker thread posts the event that triggers the main thread to
process generated data, deadlock results.
Change-Id: I3788acef73e82aa96f2b86bcb48933d01ae86841
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
//We have to force to cleanup the main thread's event queue here
//to make sure the main GUI release all pending locks/wait conditions which
//some worker script/agent are waiting for (QQuickListModelWorkerAgent::sync() for example).
- QCoreApplication::processEvents();
- wait();
+ while (!isFinished()) {
+ // We can't simply wait here, because the worker thread will not terminate
+ // until the main thread processes the last data event it generates
+ QCoreApplication::processEvents();
+ yieldCurrentThread();
+ }
+
d->deleteLater();
}