make color parsing more robust
This commit is contained in:
parent
c1ca040f4f
commit
83e8399111
10
termite.c
10
termite.c
|
@ -337,19 +337,17 @@ static void load_config(GtkWindow *window, VteTerminal *vte,
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
|
|
||||||
for (unsigned i = 0; i < 8; i++) {
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
|
fail = true;
|
||||||
gsize length;
|
gsize length;
|
||||||
gchar **pair = g_key_file_get_string_list(config, "colors", color_names[i], &length, &error);
|
gchar **pair = g_key_file_get_string_list(config, "colors", color_names[i], &length, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
fail = true;
|
|
||||||
g_clear_error(&error);
|
g_clear_error(&error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (length != 2) {
|
if ((length == 2 && gdk_color_parse(pair[0], &palette[i]) &&
|
||||||
fail = true;
|
gdk_color_parse(pair[1], &palette[i+8]))) {
|
||||||
break;
|
fail = false;
|
||||||
}
|
}
|
||||||
gdk_color_parse(pair[0], &palette[i]);
|
|
||||||
gdk_color_parse(pair[1], &palette[i+8]);
|
|
||||||
g_strfreev(pair);
|
g_strfreev(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue