From d25c97e7c979ab7ffc9abb69aeeb9b99109ca5ec Mon Sep 17 00:00:00 2001 From: Jehan Date: Thu, 23 Jan 2025 00:52:18 +0100 Subject: [PATCH] libgimp, libgimpbase: fix passing a file spec action through the wire. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I forgot to set meta.m_file.action into the GPParamDef! 🤦 As a side update, let's store the action as gint32 in GPParamDefFile. I realized that otherwise, depending on the actual size of an enum type, when casting to a (guint32 *), we crop the value! This works out in Little Endian because we are only in small number territory, but in Big Endian, we would always crop any action value to 0! This was not the bug in this specific case, but it could become the exact same bug (always passing action 0, i.e. OPEN, through the wire) on Big Endian hardware. --- libgimp/gimpgpparams-body.c | 3 ++- libgimpbase/gimpprotocol.h | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libgimp/gimpgpparams-body.c b/libgimp/gimpgpparams-body.c index 6808bbdd3e..aaf07ec02e 100644 --- a/libgimp/gimpgpparams-body.c +++ b/libgimp/gimpgpparams-body.c @@ -352,7 +352,7 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def) file = g_file_new_for_uri (param_def->meta.m_file.default_uri); pspec = gimp_param_spec_file (name, nick, blurb, - param_def->meta.m_file.action, + (GimpFileChooserAction) param_def->meta.m_file.action, param_def->meta.m_file.none_ok, file, flags); g_clear_object (&file); @@ -673,6 +673,7 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec, param_def->param_def_type = GP_PARAM_DEF_TYPE_FILE; + param_def->meta.m_file.action = (gint32) fspec->action; param_def->meta.m_file.none_ok = fspec->none_ok; param_def->meta.m_file.default_uri = ospec->_default_value ? g_file_get_uri (G_FILE (ospec->_default_value)) : NULL; diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h index a3912f9e68..0fccb5b42f 100644 --- a/libgimpbase/gimpprotocol.h +++ b/libgimpbase/gimpprotocol.h @@ -243,9 +243,10 @@ struct _GPParamDefResource struct _GPParamDefFile { - GimpFileChooserAction action; - gint32 none_ok; - gchar *default_uri; + /* action is a GimpFileChooserAction casted to gint32. */ + gint32 action; + gint32 none_ok; + gchar *default_uri; }; struct _GPParamDef