gobject: Add g_{param_spec,signal}_is_valid_name() functions

Making this validation code public allows projects to validate a
GParamSpec name before creating it. While hard-coded GParamSpec don't
need this, we can't afford crashing the main program for dynamically
generated GParamSpec from user-created data.

In such case, we will need to validate the param names and return errors
instead of trying to create a GParamSpec with invalid names.

Includes modifications from Philip Withnall and Emmanuele Bassi to
rearrange the new function addition and split it into one function for
GParamSpecs and one for GSignals.
This commit is contained in:
Jehan
2019-12-23 18:36:21 +01:00
committed by Philip Withnall
parent fb1e416a32
commit 13d1697b67
7 changed files with 104 additions and 33 deletions

View File

@@ -395,6 +395,9 @@ GLIB_AVAILABLE_IN_ALL
GType g_param_type_register_static (const gchar *name,
const GParamSpecTypeInfo *pspec_info);
GLIB_AVAILABLE_IN_2_66
gboolean g_param_spec_is_valid_name (const gchar *name);
/* For registering builting types */
GType _g_param_type_register_static_constant (const gchar *name,
const GParamSpecTypeInfo *pspec_info,