libnm-util: handle "empty" connection-type settings correctly

nm_setting_to_hash() would return NULL if the setting had entirely
default values, but this effectively meant that you could never have a
connection whose "connection type" setting (eg, NMSettingWired) had
all default values. (This ended up not usually being a problem in
practice because most such settings had at least one property with a
mandatory string value where the GObject property had a default value
of NULL.)

However, NMSettingGeneric will have no properties, so it would always
get stripped out when converting to a hash, invalidating the
connection. Fix that.
This commit is contained in:
Dan Winship 2013-04-09 15:47:08 -04:00
parent 6cb786f569
commit 4d32618264

View file

@ -304,8 +304,8 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
}
g_free (property_specs);
/* Don't return empty hashes */
if (g_hash_table_size (hash) < 1) {
/* Don't return empty hashes, except for base types */
if (g_hash_table_size (hash) < 1 && !_nm_setting_is_base_type (setting)) {
g_hash_table_destroy (hash);
hash = NULL;
}