diff src/histogram.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 5f49f305a6b6
children 9a081164e6e3
line wrap: on
line diff
--- a/src/histogram.c	Mon Apr 06 21:52:49 2009 +0000
+++ b/src/histogram.c	Mon Apr 06 22:13:54 2009 +0000
@@ -32,7 +32,7 @@
 	gulong b[HISTMAP_SIZE];
 	gulong max[HISTMAP_SIZE];
 	
-	gint idle_id;
+	guint idle_id; /* event source id */
 	GdkPixbuf *pixbuf;
 	gint y;
 };
@@ -131,14 +131,13 @@
 static HistMap *histmap_new(void)
 {
 	HistMap *histmap = g_new0(HistMap, 1);
-	histmap->idle_id = -1;
 	return histmap;
 }
 
 void histmap_free(HistMap *histmap)
 {
 	if (!histmap) return;
-	if (histmap->idle_id != -1) g_source_remove(histmap->idle_id);
+	if (histmap->idle_id) g_source_remove(histmap->idle_id);
 	if (histmap->pixbuf) g_object_unref(histmap->pixbuf);
 	g_free(histmap);
 }
@@ -190,7 +189,7 @@
 
 const HistMap *histmap_get(FileData *fd)
 {
-	if (fd->histmap && fd->histmap->idle_id == -1) return fd->histmap; /* histmap exists and is finished */
+	if (fd->histmap && !fd->histmap->idle_id) return fd->histmap; /* histmap exists and is finished */
 	
 	return NULL;
 }
@@ -203,7 +202,7 @@
 		/* finished */
 		g_object_unref(fd->histmap->pixbuf); /*pixbuf is no longer needed */
 		fd->histmap->pixbuf = NULL;
-		fd->histmap->idle_id = -1;
+		fd->histmap->idle_id = 0;
 		file_data_send_notification(fd, NOTIFY_HISTMAP);
 		return FALSE;
 		}