[anjal] Fix for a crash, when messages are inserted. The empty nodes aren't



commit 5f901f1ba5db306413b58dffcdf7580bdfcb8534
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Wed Mar 18 01:12:22 2009 +0530

    Fix for a crash, when messages are inserted. The empty nodes aren't
    removed during prune from the hash.
---
 src/em-tree-store.c |   14 +++++++++++---
 src/em-tree-store.h |    3 ++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/em-tree-store.c b/src/em-tree-store.c
index 39b0450..ca249f8 100644
--- a/src/em-tree-store.c
+++ b/src/em-tree-store.c
@@ -91,7 +91,10 @@ emts_node_alloc(struct _EMTreeStorePrivate *p)
 	EMTreeNode *node = g_slice_alloc0(sizeof(EMTreeNode)); 
 
 	e_dlist_init(&node->children);
-
+	node->info = NULL;
+	node->latest_uid = NULL;
+	node->msg_ref = NULL;
+	
 	return node;
 }
 
@@ -661,6 +664,7 @@ emts_insert_info_base(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 		/* Allocating a new node, always 'parent' to root to start with */
 		match = emts_node_alloc(p);
 		match->info = mi;
+		match->msg_ref = (gpointer) mid;
 		match->latest_uid = mi->uid;
 		if (mid
 		    && g_hash_table_lookup(p->id_table, mid) == NULL)
@@ -690,6 +694,7 @@ emts_insert_info_base(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 				parent = emts_node_alloc(p);
 				g_hash_table_insert(p->id_table, (void *)&references->references[j], parent);
 				parent->parent = emts->root;
+				parent->msg_ref = (gpointer) &references->references[j], parent;
 				e_dlist_addtail(&emts->root->children, (EDListNode *)parent);
 			}
 
@@ -709,7 +714,7 @@ emts_insert_info_base(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 /* This is used to incrementally update the model as changes come in.
    It takes some short-cuts since we no longer have the auxillairy place-holders
    to fill out the full root tree.  It will work if messages arrive in the right order however */
- void
+static  void
 emts_insert_info_incr(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_folder *f)
 {
 	struct _EMTreeStorePrivate *p = _PRIVATE(emts);
@@ -728,6 +733,7 @@ emts_insert_info_incr(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 	match->latest_uid = mi->uid;
 	camel_message_info_ref(mi);
 	mid = camel_message_info_message_id(mi);
+	match->msg_ref = mid;
 	if (mid
 	    && g_hash_table_lookup(p->id_table, mid) == NULL)
 		g_hash_table_insert(p->id_table, (void *)mid, match);
@@ -789,6 +795,7 @@ emts_prune_empty(EMTreeStore *emts, EMTreeNode *node)
 		if (node->info == NULL) {
 			if (!node_has_children(node)) {
 				e_dlist_remove((EDListNode *)node);
+				g_hash_table_remove (p->id_table, node->msg_ref);
 				emts_node_free(p, node);
 				node = next;
 				next = node->next;
@@ -812,6 +819,7 @@ emts_prune_empty(EMTreeStore *emts, EMTreeNode *node)
 				node = node->next;
 				next = node->next;
 				e_dlist_remove((EDListNode *)save);
+				g_hash_table_remove (p->id_table, save->msg_ref);
 				emts_node_free(p, save);
 			}
 		} else {
@@ -823,7 +831,7 @@ emts_prune_empty(EMTreeStore *emts, EMTreeNode *node)
 	}
 }
 
-void
+static void
 emts_remove_info(EMTreeStore *emts, const char *uid, struct _emts_folder *f)
 {
 	struct _EMTreeStorePrivate *p = _PRIVATE(emts);
diff --git a/src/em-tree-store.h b/src/em-tree-store.h
index 0d59a44..6005e70 100644
--- a/src/em-tree-store.h
+++ b/src/em-tree-store.h
@@ -52,7 +52,8 @@ struct _EMTreeNode {
 	CamelMessageInfo *info;
 
 	unsigned int flags:4;
-	const char *latest_uid; 
+	const char *latest_uid;
+	gpointer msg_ref; 
 	EDList children;
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]