Mercurial > geeqie.yaz
comparison src/bar_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 | 7f91f906f9c2 |
comparison
equal
deleted
inserted
replaced
1522:d7206703d90f | 1523:24a12aa0cb54 |
---|---|
41 gint histogram_width; | 41 gint histogram_width; |
42 gint histogram_height; | 42 gint histogram_height; |
43 GdkPixbuf *pixbuf; | 43 GdkPixbuf *pixbuf; |
44 FileData *fd; | 44 FileData *fd; |
45 gboolean need_update; | 45 gboolean need_update; |
46 gint idle_id; | 46 guint idle_id; /* event source id */ |
47 }; | 47 }; |
48 | 48 |
49 static gboolean bar_pane_histogram_update_cb(gpointer data); | 49 static gboolean bar_pane_histogram_update_cb(gpointer data); |
50 | 50 |
51 | 51 |
61 /* histmap_get is relatively expensive, run it only when we really need it | 61 /* histmap_get is relatively expensive, run it only when we really need it |
62 and with lower priority than pixbuf_renderer | 62 and with lower priority than pixbuf_renderer |
63 FIXME: this does not work for fullscreen*/ | 63 FIXME: this does not work for fullscreen*/ |
64 if (GTK_WIDGET_DRAWABLE(phd->drawing_area)) | 64 if (GTK_WIDGET_DRAWABLE(phd->drawing_area)) |
65 { | 65 { |
66 if (phd->idle_id == -1) phd->idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, bar_pane_histogram_update_cb, phd, NULL); | 66 if (!phd->idle_id) |
67 { | |
68 phd->idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, bar_pane_histogram_update_cb, phd, NULL); | |
69 } | |
67 } | 70 } |
68 else | 71 else |
69 { | 72 { |
70 phd->need_update = TRUE; | 73 phd->need_update = TRUE; |
71 } | 74 } |
74 static gboolean bar_pane_histogram_update_cb(gpointer data) | 77 static gboolean bar_pane_histogram_update_cb(gpointer data) |
75 { | 78 { |
76 const HistMap *histmap; | 79 const HistMap *histmap; |
77 PaneHistogramData *phd = data; | 80 PaneHistogramData *phd = data; |
78 | 81 |
79 phd->idle_id = -1; | 82 phd->idle_id = 0; |
80 phd->need_update = FALSE; | 83 phd->need_update = FALSE; |
81 | 84 |
82 gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0, phd->histogram_width, phd->histogram_height); | 85 gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0, phd->histogram_width, phd->histogram_height); |
83 | 86 |
84 if (phd->fd == NULL) return FALSE; | 87 if (phd->fd == NULL) return FALSE; |
180 | 183 |
181 static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data) | 184 static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data) |
182 { | 185 { |
183 PaneHistogramData *phd = data; | 186 PaneHistogramData *phd = data; |
184 | 187 |
185 g_source_remove(phd->idle_id); | 188 if (phd->idle_id) g_source_remove(phd->idle_id); |
186 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd); | 189 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd); |
187 | 190 |
188 file_data_unref(phd->fd); | 191 file_data_unref(phd->fd); |
189 histogram_free(phd->histogram); | 192 histogram_free(phd->histogram); |
190 if (phd->pixbuf) g_object_unref(phd->pixbuf); | 193 if (phd->pixbuf) g_object_unref(phd->pixbuf); |
344 phd->pane.title = bar_pane_expander_title(title); | 347 phd->pane.title = bar_pane_expander_title(title); |
345 phd->pane.id = g_strdup(id); | 348 phd->pane.id = g_strdup(id); |
346 phd->pane.type = PANE_HISTOGRAM; | 349 phd->pane.type = PANE_HISTOGRAM; |
347 | 350 |
348 phd->pane.expanded = expanded; | 351 phd->pane.expanded = expanded; |
349 phd->idle_id = -1; | |
350 | 352 |
351 phd->histogram = histogram_new(); | 353 phd->histogram = histogram_new(); |
352 | 354 |
353 histogram_set_channel(phd->histogram, histogram_channel); | 355 histogram_set_channel(phd->histogram, histogram_channel); |
354 histogram_set_mode(phd->histogram, histogram_mode); | 356 histogram_set_mode(phd->histogram, histogram_mode); |