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
2929 _requestAssignment(Assignment::RequestCommand, requestAssignmentType, requestAssignmentPool),
3030 _currentAssignment(NULL)
3131 {
32+ // register meta type is required for queued invoke method on Assignment subclasses
33+ qRegisterMetaType<HifiSockAddr>("HifiSockAddr");
34+
3235 // set the logging target to the the CHILD_TARGET_NAME
3336 Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
3437
@@ -93,9 +96,12 @@ void AssignmentClient::readPendingDatagrams() { · 58 unmodified lines
9396 QThread *workerThread = new QThread(this);
9497
9598 connect(workerThread, SIGNAL(started()), _currentAssignment, SLOT(run()));
99+
100+ connect(_currentAssignment, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
96101 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+
99105 _currentAssignment->moveToThread(workerThread);
100106
101107 // Starts an event loop, and emits workerThread->started()
@@ -105,9 +111,6 @@ void AssignmentClient::readPendingDatagrams() { · 3 unmodified lines
105111 }
106112 }
107113 } else if (_currentAssignment) {
108−
109− qRegisterMetaType<HifiSockAddr>("HifiSockAddr");
110−
111114 // have the threaded current assignment handle this datagram
112115 QMetaObject::invokeMethod(_currentAssignment, "processDatagram", Qt::QueuedConnection,
113116 Q_ARG(const QByteArray&, QByteArray((char*) packetData, receivedBytes)),
@@ -121,6 +124,9 @@ void AssignmentClient::readPendingDatagrams() { · 7 unmodified lines
121124 }
122125
123126 void AssignmentClient::assignmentCompleted() {
127+ // reset the logging target to the the CHILD_TARGET_NAME
128+ Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
129+
124130 qDebug("Assignment finished or never started - waiting for new assignment\n");
125131
126132 // the _currentAssignment is being deleted, set our pointer to NULL
@@ -131,7 +137,4 @@ void AssignmentClient::assignmentCompleted() { · 4 unmodified lines
131137 // reset our NodeList by switching back to unassigned and clearing the list
132138 nodeList->setOwnerType(NODE_TYPE_UNASSIGNED);
133139 nodeList->reset();
134−
135− // reset the logging target to the the CHILD_TARGET_NAME
136− Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
137140 }

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