History

fix cleanup of finished assignment

Stephen Birarda committed 12 years ago

Commit 113ef1b1 parent 1e279cf1 file · +11 −8Browse files

Showing the changes to assignment-client/src/AssignmentClient.cpp (1 of 1 file). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t