comparison src/view_file_icon.c @ 111:3a69a7a3f461

Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net> * view_file_icon.c: Fix odd crash when removing files, it seems the high priority idle sync is no longer called before the treeview tries to redraw itself, so fix the cleanup of removed pointers so that they are always valid or NULL (I wonder if the priorities used by GtkTreeView have changed in newer versions of GTK?). * view_file_list.c: Fix progress bar warning when files are removed before thumbnail generation is finished.
author gqview
date Wed, 15 Nov 2006 07:19:16 +0000
parents 9d5c75b5ec28
children 55166d93498d
comparison
equal deleted inserted replaced
110:9fbf210edc6f 111:3a69a7a3f461
1 /* 1 /*
2 * GQview 2 * GQview
3 * (C) 2004 John Ellis 3 * (C) 2006 John Ellis
4 * 4 *
5 * Author: John Ellis 5 * Author: John Ellis
6 * 6 *
7 * This software is released under the GNU General Public License (GNU GPL). 7 * This software is released under the GNU General Public License (GNU GPL).
8 * Please read the included file COPYING for more information. 8 * Please read the included file COPYING for more information.
62 typedef struct _IconData IconData; 62 typedef struct _IconData IconData;
63 struct _IconData 63 struct _IconData
64 { 64 {
65 FileData fd; 65 FileData fd;
66 SelectionType selected; 66 SelectionType selected;
67 gint row;
67 }; 68 };
68 69
69 70
70 static gint iconlist_read(const gchar *path, GList **list) 71 static gint iconlist_read(const gchar *path, GList **list)
71 { 72 {
83 fd = work->data; 84 fd = work->data;
84 id = g_new0(IconData, 1); 85 id = g_new0(IconData, 1);
85 86
86 memcpy(id, fd, sizeof(FileData)); 87 memcpy(id, fd, sizeof(FileData));
87 id->selected = SELECTION_NONE; 88 id->selected = SELECTION_NONE;
89 id->row = -1;
88 90
89 work->data = id; 91 work->data = id;
90 g_free(fd); 92 g_free(fd);
91 93
92 work = work->next; 94 work = work->next;
1553 row++; 1555 row++;
1554 1556
1555 list = vficon_add_row(vfi, &iter); 1557 list = vficon_add_row(vfi, &iter);
1556 while (work && list) 1558 while (work && list)
1557 { 1559 {
1560 FileData *fd;
1561
1562 fd = work->data;
1563 ICON_DATA(fd)->row = row;
1564
1558 list->data = work->data; 1565 list->data = work->data;
1559 list = list->next; 1566 list = list->next;
1560 work = work->next; 1567 work = work->next;
1561 } 1568 }
1562 } 1569 }
1634 } 1641 }
1635 1642
1636 while (list) 1643 while (list)
1637 { 1644 {
1638 FileData *fd; 1645 FileData *fd;
1646
1639 if (work) 1647 if (work)
1640 { 1648 {
1641 fd = work->data; 1649 fd = work->data;
1642 work = work->next; 1650 work = work->next;
1643 c++; 1651 c++;
1652
1653 ICON_DATA(fd)->row = r;
1644 } 1654 }
1645 else 1655 else
1646 { 1656 {
1647 fd = NULL; 1657 fd = NULL;
1648 } 1658 }
1649 if (list) 1659
1650 { 1660 list->data = fd;
1651 list->data = fd; 1661 list = list->next;
1652 list = list->next;
1653 }
1654 } 1662 }
1655 } 1663 }
1656 1664
1657 r++; 1665 r++;
1658 while (gtk_tree_model_iter_nth_child(store, &iter, NULL, r)) 1666 while (gtk_tree_model_iter_nth_child(store, &iter, NULL, r))
2396 fd->path = g_strdup(dest); 2404 fd->path = g_strdup(dest);
2397 fd->name = filename_from_path(fd->path); 2405 fd->name = filename_from_path(fd->path);
2398 2406
2399 vfi->list = filelist_insert_sort(vfi->list, fd, vfi->sort_method, vfi->sort_ascend); 2407 vfi->list = filelist_insert_sort(vfi->list, fd, vfi->sort_method, vfi->sort_ascend);
2400 2408
2401 vficon_sync(vfi); 2409 vficon_sync_idle(vfi);
2402 ret = TRUE; 2410 ret = TRUE;
2403 } 2411 }
2404 else 2412 else
2405 { 2413 {
2406 ret = vficon_maint_removed(vfi, source, NULL); 2414 ret = vficon_maint_removed(vfi, source, NULL);
2506 } 2514 }
2507 } 2515 }
2508 2516
2509 /* Thumb loader check */ 2517 /* Thumb loader check */
2510 if (fd == vfi->thumbs_fd) vfi->thumbs_fd = NULL; 2518 if (fd == vfi->thumbs_fd) vfi->thumbs_fd = NULL;
2519 if (vfi->thumbs_count > 0) vfi->thumbs_count--;
2511 2520
2512 if (vfi->prev_selection == fd) vfi->prev_selection = NULL; 2521 if (vfi->prev_selection == fd) vfi->prev_selection = NULL;
2513 if (vfi->click_fd == fd) vfi->click_fd = NULL; 2522 if (vfi->click_fd == fd) vfi->click_fd = NULL;
2514 2523
2515 /* remove pointer to this fd from grid */ 2524 /* remove pointer to this fd from grid */
2516 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfi->listview)); 2525 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfi->listview));
2517 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, row / vfi->columns)) 2526 if (ICON_DATA(fd)->row >= 0 &&
2527 gtk_tree_model_iter_nth_child(store, &iter, NULL, ICON_DATA(fd)->row))
2518 { 2528 {
2519 GList *list; 2529 GList *list;
2520 2530
2521 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1); 2531 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
2522 list = g_list_find(list, fd); 2532 list = g_list_find(list, fd);