如果我正确理解了 QFutureWatcher 文档中的以下代码,则最后一行之间存在竞争条件:
// Instantiate the objects and connect to the finished signal.
MyClass myObject;
QFutureWatcher<int> watcher;
connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished()));
// Start the computation.
QFuture<int> future = QtConcurrent::run(...);
watcher.setFuture(future);
如果函数...
在下QtConcurrent::run(...)
一行被调用之前完成,那么watcher.finished()
信号将永远不会被触发。我的假设正确吗?如何解决此错误?