From b1178c51a38c5bc403ed150ded0e246558c93145 Mon Sep 17 00:00:00 2001 From: Jehan Date: Wed, 15 Nov 2023 02:44:12 +0100 Subject: [PATCH] libgimpconfig: support the GimpRGB format for GeglColor. Some old config files will contain (color-rgb) contents. Also some data, such as historical tool presets (.gtp files) will have such values in their (tool-options). --- libgimpconfig/gimpconfig-deserialize.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libgimpconfig/gimpconfig-deserialize.c b/libgimpconfig/gimpconfig-deserialize.c index 5abc63e9fe..8ff26f9945 100644 --- a/libgimpconfig/gimpconfig-deserialize.c +++ b/libgimpconfig/gimpconfig-deserialize.c @@ -1101,7 +1101,23 @@ gimp_config_deserialize_color (GValue *value, token = g_scanner_peek_next_token (scanner); - if (token == G_TOKEN_IDENTIFIER) + if (token == G_TOKEN_LEFT_PAREN) + { + GeglColor *color; + GimpRGB rgb; + + /* Support historical GimpRGB format which may be stored in various config + * files, but even some data (such as GTP tool presets which contains + * tool-options which are GimpContext). + */ + if (! gimp_scanner_parse_color (scanner, &rgb)) + return G_TOKEN_NONE; + + color = gegl_color_new (NULL); + gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb); + g_value_take_object (value, color); + } + else if (token == G_TOKEN_IDENTIFIER) { g_scanner_get_next_token (scanner);