From cbb333c220a8606f8d91e818027fa363b2b1b7bc Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 19 Apr 2024 18:59:27 +0200 Subject: [PATCH] app: accept a NULL default color in plug-ins. Our pluginrc code is already able to output NULL for a default NULL color, but reading was failing with the following error: > GIMP-Error: Error while parsing '/home/jehan/.config/GIMP/2.99/pluginrc' in line 289: unexpected identifier 'NULL', expected number (integer) - fatal parse error Let's support reading such a value now, especially as for Python plug-ins, we are not even able to add a default value to GeglColor arguments (cf. previous commit). --- app/plug-in/plug-in-rc.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/plug-in/plug-in-rc.c b/app/plug-in/plug-in-rc.c index 1af0be794f..b32a85f256 100644 --- a/app/plug-in/plug-in-rc.c +++ b/app/plug-in/plug-in-rc.c @@ -923,11 +923,21 @@ plug_in_proc_arg_deserialize (GScanner *scanner, goto error; } - if (! gimp_scanner_parse_int (scanner, &bpp) || - bpp > 40 || - ! gimp_scanner_parse_data (scanner, bpp, &data) || - ! gimp_scanner_parse_string (scanner, &encoding) || - ! gimp_scanner_parse_int (scanner, &profile_size)) + if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER) + { + if (g_strcmp0 (scanner->next_value.v_identifier, "NULL") != 0) + { + token = G_TOKEN_INT; + goto error; + } + g_scanner_get_next_token (scanner); + /* NULL default color. Skip. */ + } + else if (! gimp_scanner_parse_int (scanner, &bpp) || + bpp > 40 || + ! gimp_scanner_parse_data (scanner, bpp, &data) || + ! gimp_scanner_parse_string (scanner, &encoding) || + ! gimp_scanner_parse_int (scanner, &profile_size)) { g_free (data); g_free (encoding);