From d880a06e6f1a00003c2eef7d70450a518faa8f7a Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Fri, 27 Dec 2013 06:19:39 +0000 Subject: [PATCH] git-svn-id: svn://imanolbarba.net/PAD@42 c2ee353e-ed0d-4329-bf56-03aec153487f --- QChatClient/QChatClient.pro.user | 2 +- QChatClient/chatroom.cpp | 20 +++++++++++--------- build-QChatClient-Desktop-Debug/QChatClient | Bin 1870461 -> 0 bytes 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/QChatClient/QChatClient.pro.user b/QChatClient/QChatClient.pro.user index 1434025..6d9b420 100644 --- a/QChatClient/QChatClient.pro.user +++ b/QChatClient/QChatClient.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/QChatClient/chatroom.cpp b/QChatClient/chatroom.cpp index 9a9b4b6..f23cb74 100644 --- a/QChatClient/chatroom.cpp +++ b/QChatClient/chatroom.cpp @@ -200,18 +200,20 @@ void Chatroom::updateUserList(QString userlist) void Chatroom::relayMsg(string msg) { string sender = getSender(msg); - //AT LEAST SOME FUCKING SANITY CHECK... PLEASE!!! - map::iterator it = activeChats.begin(); - it = activeChats.find(sender); - if(it == activeChats.end()) + if(!ui->userList->findItems(QString::fromStdString(sender),Qt::MatchExactly | Qt::MatchCaseSensitive).isEmpty()) { - chatLock->lock(); - emit createChat(QString::fromStdString(sender)); - chatCreated.wait(*chatLock); - chatLock->unlock(); + map::iterator it = activeChats.begin(); it = activeChats.find(sender); + if(it == activeChats.end()) + { + chatLock->lock(); + emit createChat(QString::fromStdString(sender)); + chatCreated.wait(*chatLock); + chatLock->unlock(); + it = activeChats.find(sender); + } + ((ChatWindow*)it->second)->notifyPrint(msg); } - ((ChatWindow*)it->second)->notifyPrint(msg); //NOT GOOD! } void Chatroom::newChat(QString peerNick) diff --git a/build-QChatClient-Desktop-Debug/QChatClient b/build-QChatClient-Desktop-Debug/QChatClient index 578e66e..20ab739 100755 Binary files a/build-QChatClient-Desktop-Debug/QChatClient and b/build-QChatClient-Desktop-Debug/QChatClient differ -- libgit2 0.22.2