[glib] install_property_internal(): Propagate failure when installing duplicated properties
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] install_property_internal(): Propagate failure when installing duplicated properties
- Date: Mon, 11 Sep 2017 17:46:31 +0000 (UTC)
commit e667d0d4c0ae16b01b0f72093a6b448889b2f621
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Sep 11 09:30:08 2017 -0500
install_property_internal(): Propagate failure when installing duplicated properties
https://bugzilla.gnome.org/show_bug.cgi?id=787551
gobject/gobject.c | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 5b0926b..762bb92 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -511,7 +511,7 @@ g_object_do_class_init (GObjectClass *class)
g_type_add_interface_check (NULL, object_interface_check_properties);
}
-static inline void
+static inline gboolean
install_property_internal (GType g_type,
guint property_id,
GParamSpec *pspec)
@@ -521,12 +521,13 @@ install_property_internal (GType g_type,
g_warning ("When installing property: type '%s' already has a property named '%s'",
g_type_name (g_type),
pspec->name);
- return;
+ return FALSE;
}
g_param_spec_ref_sink (pspec);
PARAM_SPEC_SET_PARAM_ID (pspec, property_id);
g_param_spec_pool_insert (pspec_pool, pspec, g_type);
+ return TRUE;
}
static gboolean
@@ -549,19 +550,22 @@ validate_and_install_class_property (GObjectClass *class,
g_return_val_if_fail (pspec->flags & G_PARAM_WRITABLE, FALSE);
class->flags |= CLASS_HAS_PROPS_FLAG;
- install_property_internal (oclass_type, property_id, pspec);
-
- if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
- class->construct_properties = g_slist_append (class->construct_properties, pspec);
+ if (install_property_internal (oclass_type, property_id, pspec))
+ {
+ if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
+ class->construct_properties = g_slist_append (class->construct_properties, pspec);
- /* for property overrides of construct properties, we have to get rid
- * of the overidden inherited construct property
- */
- pspec = g_param_spec_pool_lookup (pspec_pool, pspec->name, parent_type, TRUE);
- if (pspec && pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
- class->construct_properties = g_slist_remove (class->construct_properties, pspec);
+ /* for property overrides of construct properties, we have to get rid
+ * of the overidden inherited construct property
+ */
+ pspec = g_param_spec_pool_lookup (pspec_pool, pspec->name, parent_type, TRUE);
+ if (pspec && pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
+ class->construct_properties = g_slist_remove (class->construct_properties, pspec);
- return TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
/**
@@ -751,7 +755,7 @@ g_object_interface_install_property (gpointer g_iface,
if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
g_return_if_fail (pspec->flags & G_PARAM_WRITABLE);
- install_property_internal (iface_class->g_type, 0, pspec);
+ (void) install_property_internal (iface_class->g_type, 0, pspec);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]