[glib] GObjectClass: Validate installing property/properties in the same way



commit 7d9a6c86872257c6f32a44e2c792794e0447540b
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 11 08:54:19 2017 -0500

    GObjectClass: Validate installing property/properties in the same way
    
    Then we'll be able to factor out duplicated code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787551

 gobject/gobject.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index b59cf8b..7dc6bfe 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -552,25 +552,24 @@ g_object_class_install_property (GObjectClass *class,
                                 GParamSpec   *pspec)
 {
   g_return_if_fail (G_IS_OBJECT_CLASS (class));
-  g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+  g_return_if_fail (property_id > 0);
 
   if (CLASS_HAS_DERIVED_CLASS (class))
     g_error ("Attempt to add property %s::%s to class after it was derived", G_OBJECT_CLASS_NAME (class), 
pspec->name);
 
-  class->flags |= CLASS_HAS_PROPS_FLAG;
-
+  g_return_if_fail (G_IS_PARAM_SPEC (pspec));
   g_return_if_fail (pspec->flags & (G_PARAM_READABLE | G_PARAM_WRITABLE));
   if (pspec->flags & G_PARAM_WRITABLE)
     g_return_if_fail (class->set_property != NULL);
   if (pspec->flags & G_PARAM_READABLE)
     g_return_if_fail (class->get_property != NULL);
-  g_return_if_fail (property_id > 0);
   g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0); /* paranoid */
   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);
 
+  class->flags |= CLASS_HAS_PROPS_FLAG;
   install_property_internal (G_OBJECT_CLASS_TYPE (class), property_id, pspec);
 
   if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
@@ -679,8 +678,8 @@ g_object_class_install_properties (GObjectClass  *oclass,
     {
       GParamSpec *pspec = pspecs[i];
 
-      g_return_if_fail (pspec != NULL);
-
+      g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+      g_return_if_fail (pspec->flags & (G_PARAM_READABLE | G_PARAM_WRITABLE));
       if (pspec->flags & G_PARAM_WRITABLE)
         g_return_if_fail (oclass->set_property != NULL);
       if (pspec->flags & G_PARAM_READABLE)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]