标签:function quit oid loop thread success master open .exe
void QThread::run() { (void) exec(); } int QThread::exec() { Q_D(QThread); QMutexLocker locker(&d->mutex); d->data->quitNow = false; if (d->exited) { d->exited = false; return d->returnCode; } locker.unlock(); QEventLoop eventLoop; int returnCode = eventLoop.exec(); locker.relock(); d->exited = false; d->returnCode = -1; return returnCode; } void QThread::exit(int returnCode) { Q_D(QThread); QMutexLocker locker(&d->mutex); d->exited = true; d->returnCode = returnCode; d->data->quitNow = true; for (int i = 0; i < d->data->eventLoops.size(); ++i) { QEventLoop *eventLoop = d->data->eventLoops.at(i); eventLoop->exit(returnCode); } } /*! Tells the thread‘s event loop to exit with return code 0 (success). Equivalent to calling QThread::exit(0). This function does nothing if the thread does not have an event loop. \sa exit(), QEventLoop */ void QThread::quit() { exit(); }
https://github.com/openwebos/qt/blob/master/src/corelib/thread/qthread.cpp
QThread的源码(直接搜索"thread.cpp"即可,或者在github里搜)
标签:function quit oid loop thread success master open .exe
原文地址:http://www.cnblogs.com/findumars/p/6294810.html