0.8.8claws118
authorChristoph Hohmann <reboot@gmx.ch>
Sun, 19 Jan 2003 11:17:31 +0000 (11:17 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sun, 19 Jan 2003 11:17:31 +0000 (11:17 +0000)
* src/procmsg.c
        fix infinite loop in procmsg_find_children

ChangeLog.claws
configure.ac
src/procmsg.c

index 7f5fa64..a384928 100644 (file)
@@ -1,3 +1,10 @@
+2003-01-19 [christoph] 0.8.8claws118
+
+       * src/procmsg.c
+               fix infinite loop in procmsg_find_children
+
+       Patch submitted by Ivan F. Martinez <ivanfm@users.sourceforge.net>
+
 2003-01-19 [paul]      0.8.8claws117
 
        * po/pt_BR.po
index d321bea..88dc6da 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws117
+EXTRA_VERSION=claws118
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index f1cd5a3..2a05588 100644 (file)
@@ -1689,26 +1689,46 @@ gboolean procmsg_msg_has_marked_parent(MsgInfo *info)
 }
 
 
-GSList *procmsg_find_children (MsgInfo *info)
+GSList *procmsg_find_children_func(MsgInfo *info, 
+                                  GSList *children, GSList *all)
 {
-       GSList *children = NULL;
-       GSList *all, *cur;
+       GSList *cur;
 
-       g_return_val_if_fail(info!=NULL, NULL);
+       g_return_val_if_fail(info!=NULL, children);
        if (info->msgid == NULL)
-               return NULL;
-       all = folder_item_get_msg_list(info->folder);
+               return children;
+
        for (cur = all; cur != NULL; cur = g_slist_next(cur)) {
                MsgInfo *tmp = (MsgInfo *)cur->data;
                if (tmp->inreplyto && !strcmp(tmp->inreplyto, info->msgid)) {
-                       GSList *grand_children;
-                       children = g_slist_prepend(children, tmp);
-                       grand_children = procmsg_find_children(tmp);
-                       children = slist_concat_unique(children, grand_children);
-                       g_slist_free(grand_children);
+                       /* Check if message is already in the list */
+                       if ((children == NULL) || 
+                           (g_slist_index(children, tmp) == -1)) {
+                               children = g_slist_prepend(children,
+                                               procmsg_msginfo_new_ref(tmp));
+                               children = procmsg_find_children_func(tmp, 
+                                                       children, 
+                                                       all);
+                       }
+               }
+       }
+       return children;
+}
+
+GSList *procmsg_find_children (MsgInfo *info)
+{
+       GSList *children;
+       GSList *all, *cur;
+
+       g_return_val_if_fail(info!=NULL, NULL);
+       all = folder_item_get_msg_list(info->folder);
+       children = procmsg_find_children_func(info, NULL, all);
+       if (children != NULL) {
+               for (cur = all; cur != NULL; cur = g_slist_next(cur)) {
+                       /* this will not free the used pointers
+                          created with procmsg_msginfo_new_ref */
+                       procmsg_msginfo_free((MsgInfo *)cur->data);
                }
-               if (tmp && tmp != info)
-                       procmsg_msginfo_free(tmp);
        }
        g_slist_free(all);