mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
validate_pspec_to_install(): Factor out function to validate a GParamSpec
This was duplicated also in g_object_interface_install_property(). Now, validations specific to classes happen in validate_and_install_class_property() - specifically, the checks for the presence of the get_property() and set_property() methods. https://bugzilla.gnome.org/show_bug.cgi?id=787551
This commit is contained in:
parent
20720eaf1e
commit
51e852e5d0
@ -530,6 +530,23 @@ install_property_internal (GType g_type,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
validate_pspec_to_install (GParamSpec *pspec)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
|
||||
g_return_val_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0, FALSE); /* paranoid */
|
||||
|
||||
g_return_val_if_fail (pspec->flags & (G_PARAM_READABLE | G_PARAM_WRITABLE), FALSE);
|
||||
|
||||
if (pspec->flags & G_PARAM_CONSTRUCT)
|
||||
g_return_val_if_fail ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) == 0, FALSE);
|
||||
|
||||
if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
|
||||
g_return_val_if_fail (pspec->flags & G_PARAM_WRITABLE, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
validate_and_install_class_property (GObjectClass *class,
|
||||
GType oclass_type,
|
||||
@ -537,13 +554,8 @@ validate_and_install_class_property (GObjectClass *class,
|
||||
guint property_id,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
|
||||
g_return_val_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0, FALSE); /* paranoid */
|
||||
g_return_val_if_fail (pspec->flags & (G_PARAM_READABLE | G_PARAM_WRITABLE), FALSE);
|
||||
if (pspec->flags & G_PARAM_CONSTRUCT)
|
||||
g_return_val_if_fail ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) == 0, FALSE);
|
||||
if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
|
||||
g_return_val_if_fail (pspec->flags & G_PARAM_WRITABLE, FALSE);
|
||||
if (!validate_pspec_to_install (pspec))
|
||||
return FALSE;
|
||||
|
||||
if (pspec->flags & G_PARAM_WRITABLE)
|
||||
g_return_val_if_fail (class->set_property != NULL, FALSE);
|
||||
@ -748,14 +760,8 @@ g_object_interface_install_property (gpointer g_iface,
|
||||
g_return_if_fail (G_TYPE_IS_INTERFACE (iface_class->g_type));
|
||||
g_return_if_fail (!G_IS_PARAM_SPEC_OVERRIDE (pspec)); /* paranoid */
|
||||
|
||||
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
||||
g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0); /* paranoid */
|
||||
|
||||
g_return_if_fail (pspec->flags & (G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
if (pspec->flags & G_PARAM_CONSTRUCT)
|
||||
g_return_if_fail ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) == 0);
|
||||
if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
|
||||
g_return_if_fail (pspec->flags & G_PARAM_WRITABLE);
|
||||
if (!validate_pspec_to_install (pspec))
|
||||
return;
|
||||
|
||||
(void) install_property_internal (iface_class->g_type, 0, pspec);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user