mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-12 19:06:36 +00:00
Border cases of scale < 1 would lead to negative lengths, crashing conky
e.g. in the beginning the scale is always 0, leading to NaN and a crash fixes the "show_graph_scale" not working bug, not yet reported (even though I actually noticed that before, didn't seem to bother me) also cpugauge works again because fo this BUILD_MATH MATH problem
This commit is contained in:
parent
a85ffd5d0d
commit
e7cdccd964
13
src/conky.cc
13
src/conky.cc
@ -281,7 +281,7 @@ static void print_version(void)
|
|||||||
#endif /* BUILD_MYSQL */
|
#endif /* BUILD_MYSQL */
|
||||||
#ifdef BUILD_WEATHER_METAR
|
#ifdef BUILD_WEATHER_METAR
|
||||||
<< _(" * Weather (METAR)\n")
|
<< _(" * Weather (METAR)\n")
|
||||||
#endif /* BUILD_WEATHER_METAR */
|
#endif /* BUILD_WEATHER_METAR */
|
||||||
#ifdef BUILD_WEATHER_XOAP
|
#ifdef BUILD_WEATHER_XOAP
|
||||||
<< _(" * Weather (XOAP)\n")
|
<< _(" * Weather (XOAP)\n")
|
||||||
#endif /* BUILD_WEATHER_XOAP */
|
#endif /* BUILD_WEATHER_XOAP */
|
||||||
@ -1690,9 +1690,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
char *tmp_str;
|
char *tmp_str;
|
||||||
cur_x += font_ascent() / 2;
|
cur_x += font_ascent() / 2;
|
||||||
cur_y += font_h / 2;
|
cur_y += font_h / 2;
|
||||||
tmp_str = (char *)
|
const int tmp_str_len = 64;
|
||||||
calloc(log10(floor(current->scale)) + 4,
|
tmp_str = (char *) calloc(tmp_str_len, sizeof(char));
|
||||||
sizeof(char));
|
|
||||||
sprintf(tmp_str, "%.1f", current->scale);
|
sprintf(tmp_str, "%.1f", current->scale);
|
||||||
draw_string(tmp_str);
|
draw_string(tmp_str);
|
||||||
free(tmp_str);
|
free(tmp_str);
|
||||||
@ -2007,7 +2006,7 @@ static void clear_text(int exposures)
|
|||||||
/* there is some extra space for borders and outlines */
|
/* there is some extra space for borders and outlines */
|
||||||
int border_total = get_border_total();
|
int border_total = get_border_total();
|
||||||
|
|
||||||
XClearArea(display, window.window, text_start_x - border_total,
|
XClearArea(display, window.window, text_start_x - border_total,
|
||||||
text_start_y - border_total, text_width + 2*border_total,
|
text_start_y - border_total, text_width + 2*border_total,
|
||||||
text_height + 2*border_total, exposures ? True : 0);
|
text_height + 2*border_total, exposures ? True : 0);
|
||||||
}
|
}
|
||||||
@ -2142,7 +2141,7 @@ static void main_loop(void)
|
|||||||
XFreePixmap(display, window.back_buffer);
|
XFreePixmap(display, window.back_buffer);
|
||||||
window.back_buffer = XCreatePixmap(display,
|
window.back_buffer = XCreatePixmap(display,
|
||||||
window.window, window.width, window.height, DefaultDepth(display, screen));
|
window.window, window.width, window.height, DefaultDepth(display, screen));
|
||||||
|
|
||||||
if (window.back_buffer != None) {
|
if (window.back_buffer != None) {
|
||||||
window.drawable = window.back_buffer;
|
window.drawable = window.back_buffer;
|
||||||
} else {
|
} else {
|
||||||
@ -2721,7 +2720,7 @@ void load_config_file()
|
|||||||
l.replace(-2);
|
l.replace(-2);
|
||||||
if(l.type(-1) != lua::TSTRING)
|
if(l.type(-1) != lua::TSTRING)
|
||||||
throw conky::error(_("missing text block in configuration"));
|
throw conky::error(_("missing text block in configuration"));
|
||||||
|
|
||||||
/* Remove \\-\n. */
|
/* Remove \\-\n. */
|
||||||
l.gsub(l.tocstring(-1), "\\\n", "");
|
l.gsub(l.tocstring(-1), "\\\n", "");
|
||||||
l.replace(-2);
|
l.replace(-2);
|
||||||
|
@ -289,8 +289,6 @@ char *scan_graph(struct text_object *obj, const char *args, double defscale)
|
|||||||
buf[_size] = 0;
|
buf[_size] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef g
|
|
||||||
|
|
||||||
return strndup(buf, text_buffer_size.get(*state));
|
return strndup(buf, text_buffer_size.get(*state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,6 +415,9 @@ void new_font(struct text_object *obj, char *p, int p_max_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds value f to graph possibly truncating and scaling the graph
|
||||||
|
**/
|
||||||
static void graph_append(struct special_t *graph, double f, char showaslog)
|
static void graph_append(struct special_t *graph, double f, char showaslog)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -497,7 +498,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
|||||||
|
|
||||||
s = new_special(buf, GRAPH);
|
s = new_special(buf, GRAPH);
|
||||||
|
|
||||||
/* set graph (special) width to width in obj */
|
/* set graph (special) width to width in obj */
|
||||||
s->width = g->width;
|
s->width = g->width;
|
||||||
if (s->width) s->graph_width = s->width;
|
if (s->width) s->graph_width = s->width;
|
||||||
|
|
||||||
@ -537,7 +538,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
|||||||
s->scale = log10(s->scale + 1);
|
s->scale = log10(s->scale + 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
graph_append(s, val, g->flags & SF_SHOWLOG);
|
graph_append(s, val, g->flags);
|
||||||
|
|
||||||
if (not out_to_x.get(*state))
|
if (not out_to_x.get(*state))
|
||||||
new_graph_in_shell(s, buf, buf_max_size);
|
new_graph_in_shell(s, buf, buf_max_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user