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.
This commit is contained in:
@@ -766,7 +766,6 @@ _nm_setting_new_from_dbus (GType setting_type,
|
|||||||
GVariant *connection_dict,
|
GVariant *connection_dict,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSettingClass *class;
|
|
||||||
NMSetting *setting;
|
NMSetting *setting;
|
||||||
const NMSettingProperty *properties;
|
const NMSettingProperty *properties;
|
||||||
guint n_properties;
|
guint n_properties;
|
||||||
@@ -781,11 +780,6 @@ _nm_setting_new_from_dbus (GType setting_type,
|
|||||||
if (connection_dict)
|
if (connection_dict)
|
||||||
g_return_val_if_fail (g_variant_is_of_type (connection_dict, NM_VARIANT_TYPE_CONNECTION), NULL);
|
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
|
/* 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
|
* that any propreties in @setting_dict that we don't know about can
|
||||||
* either be ignored or else has a backward-compatibility equivalent
|
* 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);
|
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++) {
|
for (i = 0; i < n_properties; i++) {
|
||||||
const NMSettingProperty *property = &properties[i];
|
const NMSettingProperty *property = &properties[i];
|
||||||
GVariant *value;
|
GVariant *value;
|
||||||
@@ -825,8 +819,6 @@ _nm_setting_new_from_dbus (GType setting_type,
|
|||||||
g_variant_unref (value);
|
g_variant_unref (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_type_class_unref (class);
|
|
||||||
|
|
||||||
return setting;
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user