Showing the changes to libraries/networking/src/ThreadedAssignment.cpp (1 of 13 files). Show all
Unified · Split
| @@ -27,40 +27,42 @@ ThreadedAssignment::ThreadedAssignment(const QByteArray& packet) : · 26 unmodified lines | ||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | void ThreadedAssignment::setFinished(bool isFinished) { |
| 30 | − _isFinished = isFinished; | |
| 30 | + if (_isFinished != isFinished) { | |
| 31 | + _isFinished = isFinished; | |
| 31 | 32 | |
| 32 | − if (_isFinished) { | |
| 33 | − if (_domainServerTimer) { | |
| 34 | − _domainServerTimer->stop(); | |
| 35 | − delete _domainServerTimer; | |
| 36 | − _domainServerTimer = nullptr; | |
| 37 | − } | |
| 38 | − if (_statsTimer) { | |
| 39 | − _statsTimer->stop(); | |
| 40 | − delete _statsTimer; | |
| 41 | − _statsTimer = nullptr; | |
| 42 | − } | |
| 33 | + if (_isFinished) { | |
| 34 | + | |
| 35 | + qDebug() << "Somebody set us finished"; | |
| 36 | + | |
| 37 | + if (_domainServerTimer) { | |
| 38 | + _domainServerTimer->stop(); | |
| 39 | + } | |
| 40 | + | |
| 41 | + if (_statsTimer) { | |
| 42 | + _statsTimer->stop(); | |
| 43 | + } | |
| 43 | 44 | |
| 44 | − aboutToFinish(); | |
| 45 | − | |
| 46 | − auto nodeList = DependencyManager::get<NodeList>(); | |
| 47 | − | |
| 48 | − // if we have a datagram processing thread, quit it and wait on it to make sure that | |
| 49 | − // the node socket is back on the same thread as the NodeList | |
| 50 | − | |
| 51 | − if (_datagramProcessingThread) { | |
| 52 | − // tell the datagram processing thread to quit and wait until it is done, then return the node socket to the NodeList | |
| 53 | − _datagramProcessingThread->quit(); | |
| 54 | − _datagramProcessingThread->wait(); | |
| 45 | + aboutToFinish(); | |
| 46 | + | |
| 47 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 48 | + | |
| 49 | + // if we have a datagram processing thread, quit it and wait on it to make sure that | |
| 50 | + // the node socket is back on the same thread as the NodeList | |
| 51 | + | |
| 52 | + if (_datagramProcessingThread) { | |
| 53 | + // tell the datagram processing thread to quit and wait until it is done, then return the node socket to the NodeList | |
| 54 | + _datagramProcessingThread->quit(); | |
| 55 | + _datagramProcessingThread->wait(); | |
| 56 | + | |
| 57 | + // set node socket parent back to NodeList | |
| 58 | + nodeList->getNodeSocket().setParent(nodeList.data()); | |
| 59 | + } | |
| 60 | + | |
| 61 | + // move the NodeList back to the QCoreApplication instance's thread | |
| 62 | + nodeList->moveToThread(QCoreApplication::instance()->thread()); | |
| 55 | 63 | |
| 56 | − // set node socket parent back to NodeList | |
| 57 | − nodeList->getNodeSocket().setParent(nodeList.data()); | |
| 64 | + emit finished(); | |
| 58 | 65 | } |
| 59 | − | |
| 60 | − // move the NodeList back to the QCoreApplication instance's thread | |
| 61 | − nodeList->moveToThread(QCoreApplication::instance()->thread()); | |
| 62 | − | |
| 63 | − emit finished(); | |
| 64 | 66 | } |
| 65 | 67 | } |
| 66 | 68 | |