Permalink
Browse files

Fixed segfault issue in server.

  • Loading branch information...
1 parent 313fac0 commit c45983eeef6e6daf64e78cbf1475680d50591cb4 Matthew Via committed May 3, 2011
Showing with 6 additions and 6 deletions.
  1. +6 −6 testServer/ChatServerThread.cpp
@@ -38,31 +38,31 @@ void ChatServerThread::run() {
continue;
in >> length >> type >> data;
cout << "received type " << type << ": " << data << endl;
- QLinkedList<ChatServerThread *>::const_iterator iter = clients->constBegin();
- QLinkedList<ChatServerThread *>::iterator i = clients->begin();
+ QLinkedList<ChatServerThread *>::const_iterator iter;
+ QLinkedList<ChatServerThread *>::iterator i;
switch (type) {
case 1:
name = new QString(data);
cout << *name << endl;
break;
case 2:
- for (; iter != clients->constEnd(); ++iter) {
+ for (iter = clients->constBegin(); iter != clients->constEnd(); ++iter) {
(*iter)->addLine(5, *name + QString(": ") + data);
}
break;
case 3:
- for (; i != clients->end(); ++i) {
+ for (i = clients->begin(); i != clients->end(); ++i) {
if ((*i) == this) {
- clients->erase(i);
+ i = clients->erase(i);
}
}
terminate();
break;
case 4:
QStringList names;
QLinkedList<ChatServerThread *>::const_iterator iter = clients->constBegin();
- for (; iter != clients->constEnd(); ++iter) {
+ for (iter = clients->constBegin(); iter != clients->constEnd(); ++iter) {
names << (*iter)->getName();
}

0 comments on commit c45983e

Please sign in to comment.