add error reporting for color parsing

This commit is contained in:
Daniel Micay 2012-06-19 15:59:36 -04:00
parent adf0df826b
commit 86baaf5508
1 changed files with 10 additions and 9 deletions

View File

@ -393,20 +393,21 @@ static void load_config(GtkWindow *window, VteTerminal *vte,
"blue", "magenta", "cyan", "white"}; "blue", "magenta", "cyan", "white"};
bool success = true; bool success = true;
for (unsigned i = 0; i < 8; i++) { for (unsigned i = 0; success && i < 8; i++) {
GError *error = NULL; GError *error = NULL;
gsize length; gsize length;
char **pair = g_key_file_get_string_list(config, "colors", colors[i], &length, &error); char **pair = g_key_file_get_string_list(config, "colors", colors[i], &length, &error);
success = false;
if (error) { if (error) {
success = false;
g_error_free(error); g_error_free(error);
break; } else if (length != 2) {
} g_printerr("%s is not set to a pair of color strings\n", colors[i]);
if ((length != 2 || !gdk_color_parse(pair[0], &palette[i]) || } else if (!gdk_color_parse(pair[0], &palette[i])) {
!gdk_color_parse(pair[1], &palette[i+8]))) { g_printerr("invalid color string: %s\n", pair[0]);
success = false; } else if (!gdk_color_parse(pair[1], &palette[i+8])) {
g_strfreev(pair); g_printerr("invalid color string: %s\n", pair[1]);
break; } else {
success = true;
} }
g_strfreev(pair); g_strfreev(pair);
} }