0.9.4claws67
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 6 Sep 2003 23:18:53 +0000 (23:18 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 6 Sep 2003 23:18:53 +0000 (23:18 +0000)
* src/folder.c
* src/folderview.c
        invoke notification hook for folder tree changes after append
        and remove folder

(closes Bug 294 Crash while moving folder with many subdirectories)

ChangeLog.claws
configure.ac
src/folder.c
src/folderview.c

index 11ed518..3ac702b 100644 (file)
@@ -1,3 +1,12 @@
+2003-09-06 [christoph] 0.9.4claws67
+
+       * src/folder.c
+       * src/folderview.c
+               invoke notification hook for folder tree changes after append
+               and remove folder
+
+       (closes Bug 294 Crash while moving folder with many subdirectories)
+
 2003-09-06 [christoph] 0.9.4claws66
 
        * src/folder.c
index 743064d..56584f3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=66
+EXTRA_VERSION=67
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 692e3a0..3271521 100644 (file)
@@ -217,6 +217,8 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
 
 void folder_item_append(FolderItem *parent, FolderItem *item)
 {
+       FolderUpdateData hookdata;
+
        g_return_if_fail(parent != NULL);
        g_return_if_fail(parent->folder != NULL);
        g_return_if_fail(parent->node != NULL);
@@ -225,6 +227,10 @@ void folder_item_append(FolderItem *parent, FolderItem *item)
        item->parent = parent;
        item->folder = parent->folder;
        item->node = g_node_append_data(parent->node, item);
+
+       hookdata.folder = item->folder;
+       hookdata.update_flags = FOLDER_TREE_CHANGED;
+       hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
 }
 
 static gboolean folder_item_remove_func(GNode *node, gpointer data)
@@ -242,7 +248,9 @@ static gboolean folder_item_remove_func(GNode *node, gpointer data)
 
 void folder_item_remove(FolderItem *item)
 {
+       Folder *folder = item->folder;
        GNode *node;
+       FolderUpdateData hookdata;
 
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
@@ -256,6 +264,10 @@ void folder_item_remove(FolderItem *item)
        g_node_traverse(node, G_POST_ORDER, G_TRAVERSE_ALL, -1,
                        folder_item_remove_func, NULL);
        g_node_destroy(node);
+
+       hookdata.folder = folder;
+       hookdata.update_flags = FOLDER_TREE_CHANGED;
+       hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
 }
 
 void folder_item_remove_children(FolderItem *item)
@@ -339,13 +351,21 @@ gboolean folder_tree_destroy_func(GNode *node, gpointer data) {
 
 void folder_tree_destroy(Folder *folder)
 {
+       GNode *node;
+
        g_return_if_fail(folder != NULL);
+
+       node = folder->node;
        
        prefs_scoring_clear_folder(folder);
        prefs_filtering_clear_folder(folder);
 
-       if (folder->node)
-               folder_item_remove(FOLDER_ITEM(folder->node->data));
+       if (node != NULL) {
+               g_node_traverse(node, G_POST_ORDER, G_TRAVERSE_ALL, -1,
+                               folder_tree_destroy_func, NULL);
+               g_node_destroy(node);
+               folder->node = NULL;
+       }
 }
 
 void folder_add(Folder *folder)
@@ -822,6 +842,8 @@ gchar *folder_item_get_name(FolderItem *item)
 {
        gchar *name = NULL;
 
+       g_return_val_if_fail(item != NULL, g_strdup(""));
+
        switch (item->stype) {
        case F_INBOX:
                name = g_strdup(!strcmp2(item->name, INBOX_DIR) ? _("Inbox") :
@@ -1818,7 +1840,7 @@ gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
 }
 */
                
-FolderItem *folder_item_move_recursive (FolderItem *src, FolderItem *dest) 
+FolderItem *folder_item_move_recursive(FolderItem *src, FolderItem *dest) 
 {
        GSList *mlist;
        FolderItem *new_item;
@@ -1888,7 +1910,6 @@ gint folder_item_move_to(FolderItem *src, FolderItem *dest, FolderItem **new_ite
        FolderItem *tmp = dest->parent;
        gchar * src_identifier, * dst_identifier;
        gchar * phys_srcpath, * phys_dstpath;
-       GNode *src_node;
        
        while (tmp) {
                if (tmp == src) {
index c41f121..e22884f 100644 (file)
@@ -1918,8 +1918,6 @@ static void folderview_new_folder_cb(FolderView *folderview, guint action,
        } 
        g_free(new_folder);
 
-       folderview_create_folder_node(folderview, new_item);
-
        folder_write_list();
 }
 
@@ -2128,6 +2126,14 @@ static void folderview_delete_folder_cb(FolderView *folderview, guint action,
        Xstrdup_a(old_path, item->path, return);
        old_id = folder_item_get_identifier(item);
 
+       if (folderview->opened == folderview->selected ||
+           gtk_ctree_is_ancestor(ctree,
+                                 folderview->selected,
+                                 folderview->opened)) {
+               summary_clear_all(folderview->summaryview);
+               folderview->opened = NULL;
+       }
+
        if (item->folder->klass->remove_folder(item->folder, item) < 0) {
                alertpanel_error(_("Can't remove the folder `%s'."), name);
                if (folderview->opened == folderview->selected)
@@ -2137,18 +2143,6 @@ static void folderview_delete_folder_cb(FolderView *folderview, guint action,
                return;
        }
 
-       /* if (FOLDER_TYPE(item->folder) == F_MH)
-               prefs_filtering_delete_path(old_path); */
-
-       if (folderview->opened == folderview->selected ||
-           gtk_ctree_is_ancestor(ctree,
-                                 folderview->selected,
-                                 folderview->opened)) {
-               summary_clear_all(folderview->summaryview);
-               folderview->opened = NULL;
-       }
-
-       gtk_ctree_remove_node(ctree, folderview->selected);
        folder_write_list();
 
        prefs_filtering_delete_path(old_id);
@@ -2574,8 +2568,6 @@ static void folderview_move_to(FolderView *folderview, FolderItem *from_folder,
                else 
                        debug_print("can't remove src node: is null\n");
 
-               folderview_create_folder_node_recursive(folderview, new_folder);
-
                folder_item_update_recursive(new_folder, F_ITEM_UPDATE_MSGCNT);
 
                folderview_sort_folders(folderview,