diff 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
line wrap: on
line diff
--- a/src/search.c	Mon Apr 06 21:52:49 2009 +0000
+++ b/src/search.c	Mon Apr 06 22:13:54 2009 +0000
@@ -179,8 +179,8 @@
 	gint search_total;
 	gint search_buffer_count;
 
-	gint search_idle_id;
-	gint update_idle_id;
+	guint search_idle_id; /* event source id */
+	guint update_idle_id; /* event source id */
 
 	ImageLoader *img_loader;
 	CacheData   *img_cd;
@@ -686,14 +686,17 @@
 
 	search_status_update(sd);
 
-	sd->update_idle_id = -1;
+	sd->update_idle_id = 0;
 	return FALSE;
 }
 
 static void search_result_update_idle_cancel(SearchData *sd)
 {
-	if (sd->update_idle_id != -1) g_source_remove(sd->update_idle_id);
-	sd->update_idle_id = -1;
+	if (sd->update_idle_id)
+		{
+		g_source_remove(sd->update_idle_id);
+		sd->update_idle_id = 0;
+		}
 }
 
 static gboolean search_result_select_cb(GtkTreeSelection *selection, GtkTreeModel *store,
@@ -701,7 +704,7 @@
 {
 	SearchData *sd = data;
 
-	if (sd->update_idle_id == -1)
+	if (!sd->update_idle_id)
 		{
 		sd->update_idle_id = g_idle_add(search_result_update_idle_cb, sd);
 		}
@@ -1479,10 +1482,10 @@
 
 static void search_stop(SearchData *sd)
 {
-	if (sd->search_idle_id != -1)
+	if (sd->search_idle_id)
 		{
 		g_source_remove(sd->search_idle_id);
-		sd->search_idle_id = -1;
+		sd->search_idle_id = 0;
 		}
 
 	image_loader_free(sd->img_loader);
@@ -1968,7 +1971,7 @@
 		{
 		if (search_file_next(sd))
 			{
-			sd->search_idle_id = -1;
+			sd->search_idle_id = 0;
 			return FALSE;
 			}
 		return TRUE;
@@ -1976,7 +1979,7 @@
 
 	if (!sd->search_file_list && !sd->search_folder_list)
 		{
-		sd->search_idle_id = -1;
+		sd->search_idle_id = 0;
 
 		search_stop(sd);
 		search_result_thumb_step(sd);
@@ -2636,9 +2639,6 @@
 		sd->search_similarity_path = g_strdup(example_file->path);
 		}
 
-	sd->search_idle_id = -1;
-	sd->update_idle_id = -1;
-
 	sd->window = window_new(GTK_WINDOW_TOPLEVEL, "search", NULL, NULL, _("Image search"));
 
 	gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE);