soc.2009.transport: 9f887719: Fixed segfault when User was deleted twi...

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Sat Jul 18 11:30:21 EDT 2009


-----------------------------------------------------------------
Revision: 9f8877196ba856e62edc2d1eaf807d7e19cfba27
Ancestor: a77cf3f0b5ab59bc839ed55ba586fa8acc7cf0b1
Author: hanzz at soc.pidgin.im
Date: 2009-07-18T15:25:29
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/9f8877196ba856e62edc2d1eaf807d7e19cfba27

Modified files:
        user.cpp user.h usermanager.cpp

ChangeLog: 

Fixed segfault when User was deleted twice

-------------- next part --------------
============================================================
--- user.cpp	c255dc15b77825f57fdd1fb5aa6fb0986b547abe
+++ user.cpp	613a56743fabeee1f1ac841b4fbd34907b26e7bb
@@ -62,6 +62,7 @@ User::User(GlooxMessageHandler *parent, 
 	m_vip = p->sql()->isVIP(m_jid);
 	m_settings = p->sql()->getSettings(userKey);
 	m_syncTimer = 0;
+	removeTimer = 0;
 	m_readyForConnect = false;
 	m_rosterXCalled = false;
 	m_account = NULL;
============================================================
--- user.h	b38e79524dc7c25b1e5ab66cf829d89e75b185b4
+++ user.h	0e3457460a1c9c4cc14430eeff7e36dc39f2186d
@@ -168,6 +168,8 @@ class User {
 		void *protocolData() { return m_protocolData; }
 		GHashTable *mucs() { return m_mucs; }
 		std::map<std::string,Conversation> conversations() { return m_conversations; }
+		
+		guint removeTimer;
 	
 	private:
 		std::string m_userKey;
============================================================
--- usermanager.cpp	448dbaca07667f33c290b464a2fed82140756217
+++ usermanager.cpp	e6f4c839b47ff332e9f720e9510b9e3450c608fe
@@ -61,6 +61,8 @@ void UserManager::removeUser(User *user)
 	if (m_cachedUser && user->userKey() == m_cachedUser->userKey()) {
 		m_cachedUser = NULL;
 	}
+	if (user->removeTimer != 0)
+		purple_timeout_remove(user->removeTimer);
 	delete user;
 	Log().Get("logout") << "delete user; called => user is sucesfully removed";
 }
@@ -72,7 +74,7 @@ void UserManager::removeUserTimer(User *
 		m_cachedUser = NULL;
 	}
 	// this will be called by gloop after all
-	g_timeout_add(0,&deleteUser,user);
+	user->removeTimer = purple_timeout_add(0,&deleteUser,user);
 }
 
 void UserManager::buddyOnline() {


More information about the Commits mailing list