- add gkrellm_store_chartdatav() that takes a va_list instead of varargs. This fixes a potential crash caused by plugins using gkrellm_store_chartdata on win32 (same problem as with gkrellm_debug(), the win32 plugin-interface needs a va_list version of every vararg function in gkrellm).
This commit is contained in:
parent
0d35922472
commit
abcce9a6b1
26
src/chart.c
26
src/chart.c
|
@ -67,7 +67,7 @@ static gint
|
||||||
computed_index(GkrellmChart *cp, gint i)
|
computed_index(GkrellmChart *cp, gint i)
|
||||||
{
|
{
|
||||||
gint x;
|
gint x;
|
||||||
|
|
||||||
x = (cp->position + i + 1) % cp->w;
|
x = (cp->position + i + 1) % cp->w;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ chartdata_ycoord(GkrellmChart *cp, GkrellmChartdata *cd, gint yd)
|
||||||
{
|
{
|
||||||
glong y;
|
glong y;
|
||||||
guint64 Y;
|
guint64 Y;
|
||||||
|
|
||||||
if (cp->scale_max <= 0)
|
if (cp->scale_max <= 0)
|
||||||
cp->scale_max = 1;
|
cp->scale_max = 1;
|
||||||
|
|
||||||
|
@ -809,6 +809,17 @@ void
|
||||||
gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
|
gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
|
if (!cp)
|
||||||
|
return;
|
||||||
|
va_start(args, total);
|
||||||
|
gkrellm_store_chartdatav(cp, total, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args)
|
||||||
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
GkrellmChartdata *cd;
|
GkrellmChartdata *cd;
|
||||||
gulong range, total_diff;
|
gulong range, total_diff;
|
||||||
|
@ -818,10 +829,10 @@ gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
|
||||||
|
|
||||||
if (!cp)
|
if (!cp)
|
||||||
return;
|
return;
|
||||||
va_start(args, total);
|
|
||||||
for (list = cp->cd_list; list; list = list->next)
|
for (list = cp->cd_list; list; list = list->next)
|
||||||
{
|
{
|
||||||
cd = (GkrellmChartdata *) list->data;
|
cd = (GkrellmChartdata *) list->data;
|
||||||
|
//FIXME: missing check for number of passed varargs passed in "args"
|
||||||
cd->current = va_arg(args, gulong);
|
cd->current = va_arg(args, gulong);
|
||||||
if (!cd->monotonic)
|
if (!cd->monotonic)
|
||||||
{
|
{
|
||||||
|
@ -833,12 +844,11 @@ gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
|
||||||
if (cd->current < cd->previous || !cp->primed)
|
if (cd->current < cd->previous || !cp->primed)
|
||||||
cd->previous = cd->current;
|
cd->previous = cd->current;
|
||||||
}
|
}
|
||||||
va_end(args);
|
|
||||||
if (total < cp->previous_total || !cp->primed)
|
if (total < cp->previous_total || !cp->primed)
|
||||||
cp->previous_total = total; /* Wrap around, this store won't scale */
|
cp->previous_total = total; /* Wrap around, this store won't scale */
|
||||||
total_diff = total - cp->previous_total;
|
total_diff = total - cp->previous_total;
|
||||||
cp->previous_total = total;
|
cp->previous_total = total;
|
||||||
|
|
||||||
/* Increment position in circular buffer and remember the data
|
/* Increment position in circular buffer and remember the data
|
||||||
| value to be thrown out.
|
| value to be thrown out.
|
||||||
*/
|
*/
|
||||||
|
@ -1163,7 +1173,7 @@ gkrellm_draw_chart_text(GkrellmChart *cp, gint style_id, gchar *str)
|
||||||
buf[text_length] = '\0';
|
buf[text_length] = '\0';
|
||||||
printf("draw_chart_text: [%s] ", buf);
|
printf("draw_chart_text: [%s] ", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = cp->baseline_ref - tr->baseline; /* align baselines */
|
offset = cp->baseline_ref - tr->baseline; /* align baselines */
|
||||||
if (_GK.chart_text_no_fill)
|
if (_GK.chart_text_no_fill)
|
||||||
gkrellm_draw_text(cp->pixmap, ts, x, y + offset, s,
|
gkrellm_draw_text(cp->pixmap, ts, x, y + offset, s,
|
||||||
|
@ -1834,7 +1844,7 @@ gkrellm_chart_create(GtkWidget *vbox, GkrellmMonitor *mon, GkrellmChart *cp,
|
||||||
cp->config->chart_cd_list = &cp->cd_list;
|
cp->config->chart_cd_list = &cp->cd_list;
|
||||||
|
|
||||||
if (!cp->box)
|
if (!cp->box)
|
||||||
{
|
{
|
||||||
cp->box = gtk_vbox_new(FALSE, 0); /* not a hbox anymore !! */
|
cp->box = gtk_vbox_new(FALSE, 0); /* not a hbox anymore !! */
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), cp->box, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(vbox), cp->box, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
@ -2015,7 +2025,7 @@ set_grid_resolution_spin_button(GkrellmChart *cp, gint res)
|
||||||
if (!cp || !cp->config_window || !cp->config->grid_resolution_spin_button)
|
if (!cp || !cp->config_window || !cp->config->grid_resolution_spin_button)
|
||||||
return;
|
return;
|
||||||
spin = GTK_SPIN_BUTTON(cp->config->grid_resolution_spin_button);
|
spin = GTK_SPIN_BUTTON(cp->config->grid_resolution_spin_button);
|
||||||
gtk_spin_button_set_value(spin, (gfloat) res);
|
gtk_spin_button_set_value(spin, (gfloat) res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -93,6 +93,7 @@ GkrellmChartdata *gkrellm_add_chartdata(GkrellmChart *, GdkPixmap **,
|
||||||
GkrellmChartdata *gkrellm_add_default_chartdata(GkrellmChart *, gchar *);
|
GkrellmChartdata *gkrellm_add_default_chartdata(GkrellmChart *, gchar *);
|
||||||
void gkrellm_alloc_chartdata(GkrellmChart *);
|
void gkrellm_alloc_chartdata(GkrellmChart *);
|
||||||
void gkrellm_store_chartdata(GkrellmChart *, gulong, ...);
|
void gkrellm_store_chartdata(GkrellmChart *, gulong, ...);
|
||||||
|
void gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args);
|
||||||
void gkrellm_draw_chartdata(GkrellmChart *);
|
void gkrellm_draw_chartdata(GkrellmChart *);
|
||||||
void gkrellm_monotonic_chartdata(GkrellmChartdata *, gboolean);
|
void gkrellm_monotonic_chartdata(GkrellmChartdata *, gboolean);
|
||||||
gboolean gkrellm_get_chartdata_hide(GkrellmChartdata *);
|
gboolean gkrellm_get_chartdata_hide(GkrellmChartdata *);
|
||||||
|
@ -269,7 +270,7 @@ GkrellmDecalbutton *gkrellm_make_scaled_button(GkrellmPanel *p,
|
||||||
gboolean auto_hide, gboolean set_default_border,
|
gboolean auto_hide, gboolean set_default_border,
|
||||||
gint depth, gint cur_index, gint pressed_index,
|
gint depth, gint cur_index, gint pressed_index,
|
||||||
gint x, gint y, gint w, gint h);
|
gint x, gint y, gint w, gint h);
|
||||||
|
|
||||||
GkrellmDecalbutton *gkrellm_decal_is_button(GkrellmDecal *);
|
GkrellmDecalbutton *gkrellm_decal_is_button(GkrellmDecal *);
|
||||||
void gkrellm_set_in_button_callback(GkrellmDecalbutton *,
|
void gkrellm_set_in_button_callback(GkrellmDecalbutton *,
|
||||||
gint (*func)(), gpointer data);
|
gint (*func)(), gpointer data);
|
||||||
|
@ -571,7 +572,7 @@ gboolean gkrellm_disk_temperature_display(gpointer sr, gchar *disk_name,
|
||||||
gfloat t, gchar units);
|
gfloat t, gchar units);
|
||||||
void gkrellm_disk_temperature_remove(gchar *disk_name);
|
void gkrellm_disk_temperature_remove(gchar *disk_name);
|
||||||
|
|
||||||
|
|
||||||
/* Functions exported by net.c
|
/* Functions exported by net.c
|
||||||
*/
|
*/
|
||||||
gint gkrellm_net_routes(void);
|
gint gkrellm_net_routes(void);
|
||||||
|
|
|
@ -195,12 +195,16 @@ void gkrellm_alloc_chartdata(GkrellmChart *a)
|
||||||
{
|
{
|
||||||
(*(callbacks->gkrellm_alloc_chartdata))(a);
|
(*(callbacks->gkrellm_alloc_chartdata))(a);
|
||||||
}
|
}
|
||||||
void gkrellm_store_chartdata(GkrellmChart *a, gulong b, ...)
|
void gkrellm_store_chartdata(GkrellmChart *cp, gulong total, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list args;
|
||||||
va_start(ap, b);
|
va_start(args, total);
|
||||||
callbacks->gkrellm_store_chartdata(a, b, ap);
|
callbacks->gkrellm_store_chartdatav(cp, total, args);
|
||||||
va_end(ap);
|
va_end(args);
|
||||||
|
}
|
||||||
|
void gkrellm_store_chartdatav(GkrellmChart *cp, gulong total, va_list args)
|
||||||
|
{
|
||||||
|
callbacks->gkrellm_store_chartdatav(cp, total, args);
|
||||||
}
|
}
|
||||||
void gkrellm_draw_chartdata(GkrellmChart *a)
|
void gkrellm_draw_chartdata(GkrellmChart *a)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,7 @@ void win32_init_callbacks(void)
|
||||||
gkrellm_callbacks.gkrellm_add_chartdata = gkrellm_add_chartdata;
|
gkrellm_callbacks.gkrellm_add_chartdata = gkrellm_add_chartdata;
|
||||||
gkrellm_callbacks.gkrellm_add_default_chartdata = gkrellm_add_default_chartdata;
|
gkrellm_callbacks.gkrellm_add_default_chartdata = gkrellm_add_default_chartdata;
|
||||||
gkrellm_callbacks.gkrellm_alloc_chartdata = gkrellm_alloc_chartdata;
|
gkrellm_callbacks.gkrellm_alloc_chartdata = gkrellm_alloc_chartdata;
|
||||||
gkrellm_callbacks.gkrellm_store_chartdata = gkrellm_store_chartdata;
|
gkrellm_callbacks.gkrellm_store_chartdatav = gkrellm_store_chartdatav;
|
||||||
gkrellm_callbacks.gkrellm_draw_chartdata = gkrellm_draw_chartdata;
|
gkrellm_callbacks.gkrellm_draw_chartdata = gkrellm_draw_chartdata;
|
||||||
gkrellm_callbacks.gkrellm_monotonic_chartdata = gkrellm_monotonic_chartdata;
|
gkrellm_callbacks.gkrellm_monotonic_chartdata = gkrellm_monotonic_chartdata;
|
||||||
gkrellm_callbacks.gkrellm_get_chartdata_hide = gkrellm_get_chartdata_hide;
|
gkrellm_callbacks.gkrellm_get_chartdata_hide = gkrellm_get_chartdata_hide;
|
||||||
|
|
|
@ -82,7 +82,8 @@ typedef struct
|
||||||
GdkPixmap *, gchar *);
|
GdkPixmap *, gchar *);
|
||||||
GkrellmChartdata *(*gkrellm_add_default_chartdata)(GkrellmChart *, gchar *);
|
GkrellmChartdata *(*gkrellm_add_default_chartdata)(GkrellmChart *, gchar *);
|
||||||
void (*gkrellm_alloc_chartdata)(GkrellmChart *);
|
void (*gkrellm_alloc_chartdata)(GkrellmChart *);
|
||||||
void (*gkrellm_store_chartdata)(GkrellmChart *, gulong, ...);
|
// gkrellm_store_chartdata is not called from libgkrellm, only gkrellm_store_chartdatav
|
||||||
|
void (*gkrellm_store_chartdatav)(GkrellmChart *, gulong, ...);
|
||||||
void (*gkrellm_draw_chartdata)(GkrellmChart *);
|
void (*gkrellm_draw_chartdata)(GkrellmChart *);
|
||||||
void (*gkrellm_monotonic_chartdata)(GkrellmChartdata *, gboolean);
|
void (*gkrellm_monotonic_chartdata)(GkrellmChartdata *, gboolean);
|
||||||
gboolean (*gkrellm_get_chartdata_hide)(GkrellmChartdata *);
|
gboolean (*gkrellm_get_chartdata_hide)(GkrellmChartdata *);
|
||||||
|
|
Loading…
Reference in New Issue