libgimp, libgimpbase: fix passing a file spec action through the wire.

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.
This commit is contained in:
Jehan 2025-01-23 00:52:18 +01:00
parent 8db404516e
commit d25c97e7c9
2 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -243,7 +243,8 @@ struct _GPParamDefResource
struct _GPParamDefFile
{
GimpFileChooserAction action;
/* action is a GimpFileChooserAction casted to gint32. */
gint32 action;
gint32 none_ok;
gchar *default_uri;
};