From 138fd097ba32246f0ff29b544e2a9541f14868a9 Mon Sep 17 00:00:00 2001 From: "Matwey V. Kornilov" Date: Sun, 11 Feb 2018 00:44:06 +0300 Subject: [PATCH] Do not use static variable in gfx_prep_text() Move last_tabwidth to image_desc_t Signed-off-by: Matwey V. Kornilov --- src/rrd_gfx.c | 6 ++---- src/rrd_graph.c | 1 + src/rrd_graph.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index fa7b2233..a8446eb3 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -165,8 +165,6 @@ static PangoLayout *gfx_prep_text( const PangoFontDescription *pfd; cairo_t *cr = im->cr; - static double last_tabwidth = -1; - /* for performance reasons we might @@ -179,10 +177,10 @@ static PangoLayout *gfx_prep_text( gchar *utf8_text; - if (last_tabwidth < 0 || last_tabwidth != tabwidth){ + if (im->last_tabwidth < 0 || im->last_tabwidth != tabwidth){ PangoTabArray *tab_array; // fprintf(stderr,"t"); - last_tabwidth = tabwidth; + im->last_tabwidth = tabwidth; tab_array = pango_tab_array_new(tab_count, (gboolean) (1)); for (i = 1; i <= tab_count; i++) { pango_tab_array_set_tab(tab_array, diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 0b8179e9..8d07c604 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -4799,6 +4799,7 @@ void rrd_graph_init( im->ysize = 100; im->zoom = 1; im->init_mode = init_mode; + im->last_tabwidth = -1; if (init_mode == IMAGE_INIT_CAIRO) { im->font_options = cairo_font_options_create(); diff --git a/src/rrd_graph.h b/src/rrd_graph.h index ad57ffdd..51e627cc 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -354,6 +354,7 @@ typedef struct image_desc_t { enum image_init_en init_mode; /* do we need Cairo/Pango? */ double x_pixie; /* scale for X (see xtr() for reference) */ double y_pixie; /* scale for Y (see ytr() for reference) */ + double last_tabwidth; /* (see gfx_prep_text() for reference) */ } image_desc_t; /* Prototypes */ -- 2.47.2