soc.2009.vulture: 659a88b2: Fixed handling of removed blist nodes: t...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Tue Jul 21 15:30:42 EDT 2009


-----------------------------------------------------------------
Revision: 659a88b2b14098998b4755feac7b15ee2c9654e6
Ancestor: ae109c479f64c6c10ca7e3003dac924fdc223769
Author: gdick at soc.pidgin.im
Date: 2009-07-21T19:25:20
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/659a88b2b14098998b4755feac7b15ee2c9654e6

Modified files:
        vulture/purpleblist.c vulture/vultureblist.c

ChangeLog: 

Fixed handling of removed blist nodes: they're more persistent that I'd
realised.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	2d911fe2ada93f664c18255511e9eff977ff663e
+++ vulture/purpleblist.c	2bc7ea663b751be35961ceb1002894ba9bc5e296
@@ -45,19 +45,7 @@ void PurpleBlistNewNode(PurpleBlistNode 
  */
 void PurpleBlistNewNode(PurpleBlistNode *lpblistnode)
 {
-	/* As this is the first time we've seen this node, allocate some state
-	 * data. The UI will free this when it removes the corresponding UI
-	 * node.
-	 */
-
-	VULTURE_BLIST_NODE *lpvbn = (VULTURE_BLIST_NODE*)(lpblistnode->ui_data = g_new(VULTURE_BLIST_NODE, 1));
-
-	lpvbn->lpblistnode = lpblistnode;
-	lpvbn->szNodeText = NULL;
-	lpvbn->hti = NULL;
-	lpvbn->lRefCount = 1;
-	lpvbn->lpvbnParent = NULL;
-	InitializeCriticalSection(&lpvbn->cs);
+	lpblistnode->ui_data = NULL;
 }
 
 
@@ -73,9 +61,20 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 
 	if(!lpblistnode)
 		return;
-		
+
 	lpvbn = (VULTURE_BLIST_NODE*)lpblistnode->ui_data;
 
+	if(!lpvbn)
+	{
+		lpvbn = (VULTURE_BLIST_NODE*)(lpblistnode->ui_data = g_new(VULTURE_BLIST_NODE, 1));
+		lpvbn->lpblistnode = lpblistnode;
+		lpvbn->szNodeText = NULL;
+		lpvbn->hti = NULL;
+		lpvbn->lRefCount = 1;
+		lpvbn->lpvbnParent = NULL;
+		InitializeCriticalSection(&lpvbn->cs);
+	}
+
 	EnterCriticalSection(&lpvbn->cs);
 
 		if(ShouldShowNode(lpblistnode))
@@ -205,15 +204,24 @@ void PurpleBlistRemoveNode(PurpleBuddyLi
  */
 void PurpleBlistRemoveNode(PurpleBuddyList *lpbuddylist, PurpleBlistNode *lpblistnode)
 {
+	VULTURE_BLIST_NODE *lpvbn;
+
 	UNREFERENCED_PARAMETER(lpbuddylist);
 
 	if(!lpblistnode)
 		return;
 
+	lpvbn = lpblistnode->ui_data;
+
 	/* This pointer is about to become invalid. */
-	((VULTURE_BLIST_NODE*)lpblistnode->ui_data)->lpblistnode = NULL;
+	lpvbn->lpblistnode = NULL;
 
+	if(lpvbn->hti)
+		VulturePostUIMessage(VUIMSG_REMOVEBLISTNODE, lpvbn);
+
 	VultureBListNodeRelease((VULTURE_BLIST_NODE*)lpblistnode->ui_data);
+
+	lpblistnode->ui_data = NULL;
 }
 
 
============================================================
--- vulture/vultureblist.c	a347134346da08104a987c0aa867c0c44a9be6a9
+++ vulture/vultureblist.c	6b652e2f3614508a0df595c2dba5cdfb9f17104d
@@ -930,13 +930,16 @@ static void RemoveBListNode(HWND hwndBli
  */
 static void RemoveBListNode(HWND hwndBlistTree, VULTURE_BLIST_NODE *lpvbn)
 {
-	TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
-	lpvbn->hti = NULL;
+	if(lpvbn->hti)
+	{
+		TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
+		lpvbn->hti = NULL;
 
-	/* Release the reference belonging to the pointer
-	 * cached in the tree-item.
-	 */
-	VultureBListNodeRelease(lpvbn);
+		/* Release the reference belonging to the pointer
+		 * cached in the tree-item.
+		 */
+		VultureBListNodeRelease(lpvbn);
+	}
 }
 
 


More information about the Commits mailing list