[virt-tools-list] [libosinfo 4/5] media: Don't mark properties as _CONSTRUCT

Christophe Fergeau cfergeau at redhat.com
Tue Nov 27 17:50:26 UTC 2012


Marking them as _CONSTRUCT will cause the property setter to be
called at object construction time to set the property default
value. For the properties of OsinfoMedia, this causes the default
value to be stored in the entity store as the property setters
call osinfo_entity_set_param.

However, as the getters are careful to use
osinfo_entity_get_param_*_with_default, this is not useful,
and wastes memory. This can even be harmful if the default gobject
property value and the default value passed to
osinfo_entity_get_param are different, the gobject default will be
returned, which can be unexpected.
---
 osinfo/osinfo_media.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index 2c03916..596fa78 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -457,7 +457,6 @@ osinfo_media_class_init (OsinfoMediaClass *klass)
                                   _("Media provides a installer"),
                                   TRUE /* default value */,
                                   G_PARAM_READWRITE |
-                                  G_PARAM_CONSTRUCT | /* to set default value */
                                   G_PARAM_STATIC_NAME |
                                   G_PARAM_STATIC_NICK |
                                   G_PARAM_STATIC_BLURB);
@@ -473,7 +472,6 @@ osinfo_media_class_init (OsinfoMediaClass *klass)
                                   _("Media can boot directly w/o installation"),
                                   FALSE /* default value */,
                                   G_PARAM_READWRITE |
-                                  G_PARAM_CONSTRUCT | /* to set default value */
                                   G_PARAM_STATIC_NAME |
                                   G_PARAM_STATIC_NICK |
                                   G_PARAM_STATIC_BLURB);
@@ -500,7 +498,6 @@ osinfo_media_class_init (OsinfoMediaClass *klass)
                               G_MAXINT,
                               1 /* default value */,
                               G_PARAM_READWRITE |
-                              G_PARAM_CONSTRUCT | /* to set default value */
                               G_PARAM_STATIC_STRINGS);
     g_object_class_install_property (g_klass, PROP_INSTALLER_REBOOTS, pspec);
 }
-- 
1.8.0




More information about the virt-tools-list mailing list