diff --git a/libresapi/src/api/ChatHandler.cpp b/libresapi/src/api/ChatHandler.cpp index 19f268a93..fe2846a32 100644 --- a/libresapi/src/api/ChatHandler.cpp +++ b/libresapi/src/api/ChatHandler.cpp @@ -172,8 +172,20 @@ void ChatHandler::notifyChatMessage(const ChatMessage &msg) void ChatHandler::notifyChatCleared(const ChatId &chat_id) { RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ + //Remove processed messages std::list& msgs = mMsgs[chat_id]; msgs.clear(); + //Remove unprocessed messages + for(std::list::iterator lit = mRawMsgs.begin(); lit != mRawMsgs.end();) + { + ChatMessage& msg = *lit; + if (msg.chat_id == chat_id) + { + lit = mRawMsgs.erase(lit); + } else { + ++lit; + } + } } void ChatHandler::notifyChatStatus(const ChatId &chat_id, const std::string &status)