comparison src/search.c @ 1523:24a12aa0cb54

Fix up event source ids type: gint -> guint. Functions like g_timeout_add() or g_idle_add() return a guint greater than 0, but in most places it was wrongly stored as int and initialized to -1. This broke assertions matching in g_source_remove() for example since id was always greater than 0 even when timer was not set (-1 was casted to the biggest guint).
author zas_
date Mon, 06 Apr 2009 22:13:54 +0000
parents c9ed5a43c576
children 717374fb1bbd
comparison
equal deleted inserted replaced
1522:d7206703d90f 1523:24a12aa0cb54
177 177
178 gint search_count; 178 gint search_count;
179 gint search_total; 179 gint search_total;
180 gint search_buffer_count; 180 gint search_buffer_count;
181 181
182 gint search_idle_id; 182 guint search_idle_id; /* event source id */
183 gint update_idle_id; 183 guint update_idle_id; /* event source id */
184 184
185 ImageLoader *img_loader; 185 ImageLoader *img_loader;
186 CacheData *img_cd; 186 CacheData *img_cd;
187 187
188 FileData *click_fd; 188 FileData *click_fd;
684 { 684 {
685 SearchData *sd = data; 685 SearchData *sd = data;
686 686
687 search_status_update(sd); 687 search_status_update(sd);
688 688
689 sd->update_idle_id = -1; 689 sd->update_idle_id = 0;
690 return FALSE; 690 return FALSE;
691 } 691 }
692 692
693 static void search_result_update_idle_cancel(SearchData *sd) 693 static void search_result_update_idle_cancel(SearchData *sd)
694 { 694 {
695 if (sd->update_idle_id != -1) g_source_remove(sd->update_idle_id); 695 if (sd->update_idle_id)
696 sd->update_idle_id = -1; 696 {
697 g_source_remove(sd->update_idle_id);
698 sd->update_idle_id = 0;
699 }
697 } 700 }
698 701
699 static gboolean search_result_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, 702 static gboolean search_result_select_cb(GtkTreeSelection *selection, GtkTreeModel *store,
700 GtkTreePath *tpath, gboolean selected, gpointer data) 703 GtkTreePath *tpath, gboolean selected, gpointer data)
701 { 704 {
702 SearchData *sd = data; 705 SearchData *sd = data;
703 706
704 if (sd->update_idle_id == -1) 707 if (!sd->update_idle_id)
705 { 708 {
706 sd->update_idle_id = g_idle_add(search_result_update_idle_cb, sd); 709 sd->update_idle_id = g_idle_add(search_result_update_idle_cb, sd);
707 } 710 }
708 711
709 return TRUE; 712 return TRUE;
1477 sd->search_buffer_count = 0; 1480 sd->search_buffer_count = 0;
1478 } 1481 }
1479 1482
1480 static void search_stop(SearchData *sd) 1483 static void search_stop(SearchData *sd)
1481 { 1484 {
1482 if (sd->search_idle_id != -1) 1485 if (sd->search_idle_id)
1483 { 1486 {
1484 g_source_remove(sd->search_idle_id); 1487 g_source_remove(sd->search_idle_id);
1485 sd->search_idle_id = -1; 1488 sd->search_idle_id = 0;
1486 } 1489 }
1487 1490
1488 image_loader_free(sd->img_loader); 1491 image_loader_free(sd->img_loader);
1489 sd->img_loader = NULL; 1492 sd->img_loader = NULL;
1490 cache_sim_data_free(sd->img_cd); 1493 cache_sim_data_free(sd->img_cd);
1966 1969
1967 if (sd->search_file_list) 1970 if (sd->search_file_list)
1968 { 1971 {
1969 if (search_file_next(sd)) 1972 if (search_file_next(sd))
1970 { 1973 {
1971 sd->search_idle_id = -1; 1974 sd->search_idle_id = 0;
1972 return FALSE; 1975 return FALSE;
1973 } 1976 }
1974 return TRUE; 1977 return TRUE;
1975 } 1978 }
1976 1979
1977 if (!sd->search_file_list && !sd->search_folder_list) 1980 if (!sd->search_file_list && !sd->search_folder_list)
1978 { 1981 {
1979 sd->search_idle_id = -1; 1982 sd->search_idle_id = 0;
1980 1983
1981 search_stop(sd); 1984 search_stop(sd);
1982 search_result_thumb_step(sd); 1985 search_result_thumb_step(sd);
1983 1986
1984 return FALSE; 1987 return FALSE;
2634 if (example_file) 2637 if (example_file)
2635 { 2638 {
2636 sd->search_similarity_path = g_strdup(example_file->path); 2639 sd->search_similarity_path = g_strdup(example_file->path);
2637 } 2640 }
2638 2641
2639 sd->search_idle_id = -1;
2640 sd->update_idle_id = -1;
2641
2642 sd->window = window_new(GTK_WINDOW_TOPLEVEL, "search", NULL, NULL, _("Image search")); 2642 sd->window = window_new(GTK_WINDOW_TOPLEVEL, "search", NULL, NULL, _("Image search"));
2643 2643
2644 gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE); 2644 gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE);
2645 2645
2646 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE; 2646 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;