From b70bb2fc3c9164d28ea0ef2dcceed6bccea6cc8a Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 18 Jul 2013 11:19:16 +0000 Subject: [PATCH] Corrigindo segfault na impressão quando a tabela de cores está errada --- src/pw3270/print.c | 3 +++ src/pw3270/v3270/widget.c | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/pw3270/print.c b/src/pw3270/print.c index 9edce27..9f67c47 100644 --- a/src/pw3270/print.c +++ b/src/pw3270/print.c @@ -395,6 +395,9 @@ static gchar * enum_to_string(GType type, guint enum_value) { gchar *ptr = get_string_from_config("print","colors",""); + trace("info->color=%p",info->color); + trace("colorlist=%p",ptr); + if(*ptr) v3270_set_color_table(info->color,ptr); else diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index 4c02f73..f0c0af1 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -1296,15 +1296,24 @@ void v3270_set_color_table(GdkRGBA *table, const gchar *colors) g_warning("Color table has %d elements; should be %d.",cnt,V3270_COLOR_COUNT); - for(f=0;f < cnt;f++) - gdk_rgba_parse(table+f,clr[f]); - - for(f=cnt; f < V3270_COLOR_COUNT;f++) - gdk_rgba_parse(table+f,clr[cnt-1]); + if(cnt < V3270_COLOR_COUNT) + { + // Less than the required + for(f=0;f < cnt;f++) + gdk_rgba_parse(table+f,clr[f]); - clr[V3270_COLOR_OIA_BACKGROUND] = clr[0]; - clr[V3270_COLOR_SELECTED_BG] = clr[0]; + for(f=cnt; f < V3270_COLOR_COUNT;f++) + gdk_rgba_parse(table+f,clr[cnt-1]); + clr[V3270_COLOR_OIA_BACKGROUND] = clr[0]; + clr[V3270_COLOR_SELECTED_BG] = clr[0]; + } + else + { + // More than required + for(f=0;f < V3270_COLOR_COUNT;f++) + gdk_rgba_parse(table+f,clr[f]); + } } g_strfreev(clr); -- libgit2 0.21.2