Commit 64754cb2 authored by Philip Withnall's avatar Philip Withnall

signal-logger: Don’t pass NULL to G_VALUE_LCOPY()

While it may have previously worked, it’s not how the API was meant to
be used, and a change in GLib 2.66 means that it now causes a critical
warning to be emitted (see
GNOME/glib!1505 (comment 984868)).

Fix that by using a custom version of `G_VALUE_LCOPY()`.
Signed-off-by: Philip Withnall's avatarPhilip Withnall <pwithnall@endlessos.org>
parent 0c6454f4
Pipeline #238770 passed with stages
in 6 minutes and 20 seconds
......@@ -142,6 +142,29 @@ gt_signal_logger_emission_free (GtSignalLoggerEmission *emission)
g_free (emission);
}
/* Version of G_VALUE_LCOPY() that allows %NULL return locations. */
#define VALUE_LCOPY(value, var_args, __error) \
G_STMT_START { \
const GValue *_value = (value); \
GType _value_type = G_VALUE_TYPE (_value); \
GTypeValueTable *_vtable = g_type_value_table_peek (_value_type); \
const gchar *_lcopy_format = _vtable->lcopy_format; \
GTypeCValue _cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
guint _n_values = 0; \
\
while (*_lcopy_format != '\0') \
{ \
g_assert (*_lcopy_format == G_VALUE_COLLECT_POINTER); \
_cvalues[_n_values++].v_pointer = va_arg ((var_args), gpointer); \
_lcopy_format++; \
} \
\
if (_n_values == 2 && !!_cvalues[0].v_pointer != !!_cvalues[1].v_pointer) \
*(__error) = g_strdup_printf ("all return locations need the same nullability"); \
else if (_cvalues[0].v_pointer != NULL) \
*(__error) = _vtable->lcopy_value (_value, _n_values, _cvalues, 0); \
} G_STMT_END
/**
* gt_signal_logger_emission_get_params:
* @self: a #GtSignalLoggerEmission
......@@ -167,7 +190,7 @@ gt_signal_logger_emission_get_params (GtSignalLoggerEmission *self,
for (gsize i = 0; i < self->n_param_values; i++)
{
g_autofree gchar *error_message = NULL;
G_VALUE_LCOPY (&self->param_values[i], ap, 0, &error_message);
VALUE_LCOPY (&self->param_values[i], ap, &error_message);
/* Error messages are not fatal, as they typically indicate that the user
* has passed in %NULL rather than a valid return pointer. We can recover
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment