Showing the changes to assignment-client/src/AssignmentClient.cpp (1 of 1 file). Show all
Unified · Split
| @@ -29,6 +29,9 @@ AssignmentClient::AssignmentClient(int &argc, char **argv, · 28 unmodified lines | ||
| 29 | 29 | _requestAssignment(Assignment::RequestCommand, requestAssignmentType, requestAssignmentPool), |
| 30 | 30 | _currentAssignment(NULL) |
| 31 | 31 | { |
| 32 | + // register meta type is required for queued invoke method on Assignment subclasses | |
| 33 | + qRegisterMetaType<HifiSockAddr>("HifiSockAddr"); | |
| 34 | + | |
| 32 | 35 | // set the logging target to the the CHILD_TARGET_NAME |
| 33 | 36 | Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME); |
| 34 | 37 | |
| @@ -93,9 +96,12 @@ void AssignmentClient::readPendingDatagrams() { · 58 unmodified lines | ||
| 93 | 96 | QThread *workerThread = new QThread(this); |
| 94 | 97 | |
| 95 | 98 | connect(workerThread, SIGNAL(started()), _currentAssignment, SLOT(run())); |
| 99 | + | |
| 100 | + connect(_currentAssignment, SIGNAL(finished()), this, SLOT(assignmentCompleted())); | |
| 96 | 101 | connect(_currentAssignment, SIGNAL(finished()), workerThread, SLOT(quit())); |
| 97 | − connect(_currentAssignment, SIGNAL(finished()), _currentAssignment, SLOT(deleteLater())); | |
| 98 | − connect(_currentAssignment, SIGNAL(finished()), workerThread, SLOT(deleteLater())); | |
| 102 | + connect(workerThread, SIGNAL(finished()), _currentAssignment, SLOT(deleteLater())); | |
| 103 | + connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); | |
| 104 | + | |
| 99 | 105 | _currentAssignment->moveToThread(workerThread); |
| 100 | 106 | |
| 101 | 107 | // Starts an event loop, and emits workerThread->started() |
| @@ -105,9 +111,6 @@ void AssignmentClient::readPendingDatagrams() { · 3 unmodified lines | ||
| 105 | 111 | } |
| 106 | 112 | } |
| 107 | 113 | } else if (_currentAssignment) { |
| 108 | − | |
| 109 | − qRegisterMetaType<HifiSockAddr>("HifiSockAddr"); | |
| 110 | − | |
| 111 | 114 | // have the threaded current assignment handle this datagram |
| 112 | 115 | QMetaObject::invokeMethod(_currentAssignment, "processDatagram", Qt::QueuedConnection, |
| 113 | 116 | Q_ARG(const QByteArray&, QByteArray((char*) packetData, receivedBytes)), |
| @@ -121,6 +124,9 @@ void AssignmentClient::readPendingDatagrams() { · 7 unmodified lines | ||
| 121 | 124 | } |
| 122 | 125 | |
| 123 | 126 | void AssignmentClient::assignmentCompleted() { |
| 127 | + // reset the logging target to the the CHILD_TARGET_NAME | |
| 128 | + Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME); | |
| 129 | + | |
| 124 | 130 | qDebug("Assignment finished or never started - waiting for new assignment\n"); |
| 125 | 131 | |
| 126 | 132 | // the _currentAssignment is being deleted, set our pointer to NULL |
| @@ -131,7 +137,4 @@ void AssignmentClient::assignmentCompleted() { · 4 unmodified lines | ||
| 131 | 137 | // reset our NodeList by switching back to unassigned and clearing the list |
| 132 | 138 | nodeList->setOwnerType(NODE_TYPE_UNASSIGNED); |
| 133 | 139 | nodeList->reset(); |
| 134 | − | |
| 135 | − // reset the logging target to the the CHILD_TARGET_NAME | |
| 136 | − Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME); | |
| 137 | 140 | } |