Replace setting_type.new() with setting_type()

When `setting_type` is `NM.SettingMatch`, `setting_type.new()` will not
work because `nm_setting_match_new()` symbol is only exposed and usable
since libnm version 1.32 (using `setting_type.new()` is equivalent to
call libnm function `nm_setting_*_new()`).

Function `setting_type()` will always construct an instance of that
`setting_type` and will not need a workaround when `setting_type` is
`NM.SettingMatch`. So drop `setting_type.new()` in favor of
`setting_type()`.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang 2021-05-17 18:27:30 -04:00 committed by Gris Ge
parent 46ff0ece04
commit 71b4ff9357

View file

@ -705,7 +705,7 @@ class NMUtil:
def connection_ensure_setting(self, connection, setting_type):
setting = connection.get_setting(setting_type)
if not setting:
setting = setting_type.new()
setting = setting_type()
connection.add_setting(setting)
return setting