From d80e100179d408a754402d1c688052cd45bf7bfa Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 15 Jan 2015 11:09:00 -0500 Subject: [PATCH] libnm-core: simplify _nm_setting_new_from_dbus() libnm-util's nm_setting_new_from_hash() needed to call g_type_class_ref(setting_type) to ensure that the class had been initialized by the time we fetched its properties. But in libnm-core's version, we create the setting object before fetching the list of properties, so we know the class will already have been initialized by that point. --- libnm-core/nm-setting.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 48317fc7c6..4ecfb02494 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -766,7 +766,6 @@ _nm_setting_new_from_dbus (GType setting_type, GVariant *connection_dict, GError **error) { - NMSettingClass *class; NMSetting *setting; const NMSettingProperty *properties; guint n_properties; @@ -781,11 +780,6 @@ _nm_setting_new_from_dbus (GType setting_type, if (connection_dict) g_return_val_if_fail (g_variant_is_of_type (connection_dict, NM_VARIANT_TYPE_CONNECTION), NULL); - /* g_type_class_ref() ensures the setting class is created if it hasn't - * already been used. - */ - class = g_type_class_ref (setting_type); - /* Build the setting object from the properties we know about; we assume * that any propreties in @setting_dict that we don't know about can * either be ignored or else has a backward-compatibility equivalent @@ -793,7 +787,7 @@ _nm_setting_new_from_dbus (GType setting_type, */ setting = (NMSetting *) g_object_new (setting_type, NULL); - properties = nm_setting_class_get_properties (class, &n_properties); + properties = nm_setting_class_get_properties (NM_SETTING_GET_CLASS (setting), &n_properties); for (i = 0; i < n_properties; i++) { const NMSettingProperty *property = &properties[i]; GVariant *value; @@ -825,8 +819,6 @@ _nm_setting_new_from_dbus (GType setting_type, g_variant_unref (value); } - g_type_class_unref (class); - return setting; }