Changeset - 83bf526fbce9
[Not reviewed]
0 2 0
HanzZ - 14 years ago 2011-06-12 16:35:12
hanzz.k@gmail.com
Fixed deadlock while removing conversations
2 files changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/conversation.cpp
Show inline comments
 
@@ -23,24 +23,25 @@
 
#include "transport/conversationmanager.h"
 
#include "transport/user.h"
 
#include "transport/transport.h"
 
#include "transport/buddy.h"
 
#include "transport/rostermanager.h"
 

	
 
namespace Transport {
 

	
 
Conversation::Conversation(ConversationManager *conversationManager, const std::string &legacyName, bool isMUC) : m_conversationManager(conversationManager) {
 
	m_legacyName = legacyName;
 
	m_conversationManager->addConversation(this);
 
	m_muc = isMUC;
 
	std::cout << "new conversation " << legacyName << "\n";
 
}
 

	
 
Conversation::~Conversation() {
 
	m_conversationManager->removeConversation(this);
 
}
 

	
 
void Conversation::handleMessage(boost::shared_ptr<Swift::Message> &message, const std::string &nickname) {
 
	if (m_muc) {
 
		message->setType(Swift::Message::Groupchat);
 
	}
 
	else {
 
		message->setType(Swift::Message::Chat);
src/conversationmanager.cpp
Show inline comments
 
@@ -28,24 +28,25 @@
 
#include "Swiften/Elements/RosterPayload.h"
 
#include "Swiften/Elements/RosterItemPayload.h"
 

	
 
namespace Transport {
 

	
 
ConversationManager::ConversationManager(User *user, Component *component){
 
	m_user = user;
 
	m_component = component;
 
}
 

	
 
ConversationManager::~ConversationManager() {
 
	while(!m_convs.empty()) {
 
		m_convs.erase(m_convs.begin());
 
		delete (*m_convs.begin()).second;
 
	}
 
}
 

	
 
void ConversationManager::addConversation(Conversation *conv) {
 
	m_convs[conv->getLegacyName()] = conv;
 
}
 

	
 
void ConversationManager::removeConversation(Conversation *conv) {
 
	for (std::map<std::string, Conversation *>::const_iterator it = m_convs.begin(); it != m_convs.end(); it++) {
 
		if ((*it).second->getRoom() == conv->getLegacyName()) {
 
			(*it).second->setRoom("");
0 comments (0 inline, 0 general)